General information
Category:
COM/DCOM and OLE Automation
Henry,
It works if you invoke the find/replace dialog manually from within Word and set the option "search" to "ALL" there. But for some reason this setting is ignored or not able to be set via automation.
So I came up with sendkeys method and it works for me (I am in Version 8 at this moment). Possibly you will need to adjust the key combination for another Word version.
oWord = CREATEOBJECT("Word.Application")
oWord.documents.open("c:\veterans day.doc")
oWord.visible=.t.
WITH oWord.Selection.Find
.clearformatting
.Replacement.ClearFormatting
.Forward = .t.
.MatchWholeWord = .f.
.MatchCase = .f.
.Wrap = 1
.Text = "april"
.Replacement.Text = "November"
?.Execute(,,,,,,,,,, 2) &&does not work
?.Execute("april",,,,,,,1,, "November", 2) &&does not work
*oword.dialogs(117).show && usually "ALL" is already set, but does not work
ENDWITH
oWord.Application.Activate
* this works!
oWord.Wordbasic.Sendkeys("%ee%M{TAB 2}All%A{ENTER}{TAB 11}{ENTER}")
SUSPEND
oWord.QUIT(0)
oWord=.null.
>Hi,
>
>Is there a way I can automate a Find/Replace in Word that encompasses the BODY AND the HEADER of the document ?
>
>I can Find/Replace in the body with no problem. I am looking for a way to do a GLOBAL F/R in the doc.
>
>I tried .WholeStory but it really isn't the WHOLE story. Flip-flopping too much between sections invariably hangs VFP (6, btw).
>
>Any help would be greatly appreciated.
>
>Henry
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only