Group:  Microsoft Word ยป microsoft.public.word.vba.beginners
Thread: pulling text from a word document

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

pulling text from a word document
"colemandg" <dennis.coleman[ at ]wachovia.com> 31.01.2006 13:13:11
I have a word document that contains a four-column table. The first
two columns contain a Task ID and a Description of Task. One row of
the table will have something like the following for Task ID and
Description cells.

1.1 Use the 'Export' bat file to export projects. Copy exported
projects to the following folder:
L:\nBalance\Prod\BlackrockToSimcorp\Position\admin

I need to be able to find the cell that has the text: "Use the
'Export' bat file to export projects. Copy exported projects to
the following folder:", and pull out the path/directory structure that
is provided afterwards. There is a little bit of complexity in that
the path will always differ and I can not always assume that the
information is in Task 1.1.

Any thoughts on how to accomplish this?

Thanks in advance.

Re: pulling text from a word document
Cindy M -WordMVP- <C.Meister-C[ at ]hispeed.ch> 31.01.2006 16:05:33
Hi Colemandg,

[Quoted Text]
> I have a word document that contains a four-column table. The first
> two columns contain a Task ID and a Description of Task. One row of
> the table will have something like the following for Task ID and
> Description cells.
>
> 1.1 Use the 'Export' bat file to export projects. Copy exported
> projects to the following folder:
> L:\nBalance\Prod\BlackrockToSimcorp\Position\admin
>
> I need to be able to find the cell that has the text: "Use the
> 'Export' bat file to export projects. Copy exported projects to
> the following folder:", and pull out the path/directory structure that
> is provided afterwards. There is a little bit of complexity in that
> the path will always differ and I can not always assume that the
> information is in Task 1.1.
>
> Any thoughts on how to accomplish this?
>
We can assume that the path will always follow the text (plus colon and
space)?

Use the FIND property (as in Selection.Find or Range.Find) to locate the
text. Collapse the selection or range to a point. Extend it to the end
of the cell, minus two characters to pick up the path. Very roughly:

Dim rng as Word.Range

With rng.Find
.Text = "Use the 'Export' bat file to export projects. Copy
exported projects to the following folder:"
.Execute
end With
rng.Collapse wdCollapseEnd
rng.End = rng.Cells(1).Range.End
rng.MoveEnd Unit:=wdCharacter, Count:=2
strpath = rng.Text

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)

Re: pulling text from a word document
"colemandg" <dennis.coleman[ at ]wachovia.com> 31.01.2006 21:09:08
Sweet. I'll try that. Thanks.

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net