user3593103
user3593103

Reputation: 1

automation with visual foxpro

I am writing some foxpro application with a feature to find/replace text in a Word document. The following code works fine:

******************************************  begining of code

xfromfilename = "test.doc"
Wait Window "Processing, please wait ....................." Nowait

#Define  wdWindowStateNormal        0

Local nScreenHeight, nScreenWidth
Local nWindowHeight, nWindowWidth

* Compute sizes
nScreenHeight = Sysmetric(2)
nScreenWidth = Sysmetric(1)

nWindowHeight = Int(.67 * nScreenHeight)
nWindowWidth = Int(.67 * nScreenWidth)

Release All Like o*
Public oWord
oWord = Createobject("Word.Application")
oDocument = oWord.Documents.Open("&xtofilename")

#Define wdReplaceAll  2
oRange = oWord.ActiveDocument.Content

With oRange.Find
    .Text = "sample text"
    .Replacement.Text = "sample to replace text"
    .Execute( ,  , , , ,  , , , , ,  wdReplaceAll)
ENDWITH

oWord.ActiveDocument.Close()
oWord.Quit

Release oWord

*************  end of code

However, when i try to find/replace text in "textbox" contained in the Word doc, it doesn't work.

I appreciate if someone can help me out with this issue.

Thank you.

Upvotes: 0

Views: 875

Answers (1)

Tamar E. Granor
Tamar E. Granor

Reputation: 3937

I'm pretty sure text in textboxes isn't part of the range you specified with ActiveDocument.Content. You need to go through the Document's FormFields collection.

Upvotes: 0

Related Questions