I am using the Find method to locate a specific string of text in a Word doc. The Execute() is returning TRUE, so now I want an object reference to that. I am trying oRange = oWord.Selection which does return an object reference.
However, when I try to perform operations on that selection, I find that the selection [cursor position in the Word Doc] is somewhere else [e.g., the beginning of the document]. If I actually do this Find in the Word doc manually, the string is found and selected. When I do this via automation, the string is found but not selected.
The code looks like:
with loRange.Find
.ClearFormatting()
.Text = This.cFindValue
.Replacement.Text = ""
.Forward = .t.
.Wrap = wdFindContinue
.Format = .f.
.MatchCase = .f.
.MatchWholeWord = .f.
.MatchWildcards = .f.
.MatchSoundsLike = .f.
.MatchAllWordForms = .f.
llRetVal = .Execute()
endwith
if llRetVal
return This.oWord.Selection
else
return .null.
endif
What am I missing? TIA!
Mark McCasland
Midlothian, TX USA