Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find/Replace in Word
Message
 
To
19/06/2003 13:19:17
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00801843
Message ID:
00801930
Views:
17
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
Map
View

Click here to load this message in the networking platform