I've got the code to search through a directory for word documents,
open the doc, search for specific text... but I'm trying to extract
data that immediately follows the selected highlighted text. I can't
figure out the correct syntax to give me the text that follows the
currently selected text. Here is my code:
Set objword = New Word.Application
objword.Documents.Add "filename.doc"
objword.WindowState = wdWindowStateMaximize
objword.Visible = True
With objword.Selection
Do
.Find.Text = "Purpose:"
.Find.Forward = True
.Find.Wrap = wdFindStop
.Find.Format = False
.Find.MatchCase = False
.Find.MatchWholeWord = False
.Find.MatchWildcards = False
.Find.MatchSoundsLike = False
.Find.MatchAllWordForms = False
Loop While .Find.Execute = True
The doc is open and I can see the highlighted text of "Purpose:" but
it is followed by a space or two and then some text. I want to
extract the text but have tried several variations of code without
success.
Your help is greatly appreciated.