【发布时间】:2014-05-01 14:59:31
【问题描述】:
我正在编写一些具有在 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 文档中包含的“文本框”中查找/替换文本时,它不起作用。
如果有人可以帮助我解决这个问题,我将不胜感激。
谢谢。
【问题讨论】:
标签: vba visual-foxpro office-automation