Vba 用visualfoxpro实现自动化
我正在编写一些foxpro应用程序,它具有查找/替换Word文档中文本的功能。以下代码可以正常工作:Vba 用visualfoxpro实现自动化,vba,visual-foxpro,office-automation,Vba,Visual Foxpro,Office Automation,我正在编写一些foxpro应用程序,它具有查找/替换Word文档中文本的功能。以下代码可以正常工作: ****************************************** begining of code xfromfilename = "test.doc" Wait Window "Processing, please wait ....................." Nowait #Define wdWindowStateNormal 0 Loc
****************************************** 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文档中“textbox”中的文本时,它不起作用
如果有人能帮我解决这个问题,我将不胜感激
谢谢。我很确定文本框中的文本不属于您用ActiveDocument.Content指定的范围。您需要查看文档的FormFields集合