【问题标题】:automation with visual foxpro使用可视化 Foxpro 实现自动化
【发布时间】: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


    【解决方案1】:

    我很确定文本框中的文本不属于您使用 ActiveDocument.Content 指定的范围。您需要浏览 Document 的 FormFields 集合。

    【讨论】:

      猜你喜欢
      • 2016-10-10
      • 2021-09-28
      • 2018-11-27
      • 2016-11-27
      • 2017-11-13
      • 2020-01-09
      • 2014-09-03
      • 2017-11-29
      • 1970-01-01
      相关资源
      最近更新 更多