自动化与视觉foxpro
问题描述:
我正在写一些功能foxpro应用程序来查找/替换Word文档中的文本。下面的代码工作正常:自动化与视觉foxpro
****************************************** 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
然而,当我试图查找/替换中所含的Word文档“文本框”的文字,这是行不通的。
我很感谢有人能帮助我解决这个问题。
谢谢。
答
我很确定文本框中的文本不是您使用ActiveDocument.Content指定的范围的一部分。您需要浏览Document的FormFields集合。