繁体   English   中英

如何使用VBA将Word文档中的文本框值复制到其他Word文档中的文本框中(MS Word 2003)

[英]How to copy textbox value in a word document into a textbox in a different word document with VBA (MS Word 2003)

希望这是一个简单的问题。

我有两个Word文档(MS Word 2003),每个文档都有一个文本框对象。 按下命令按钮后,我希望一个文档(“ Reference_Text.docx”)的文本框中的文本进入另一文档的文本框中。

下面显示了我在按下命令按钮时试图在事件中使用的代码。 我正在尝试使用Reference_Text.docx文件中的“ txtLocation_Analysis_1”中的文本填充文本框(txtLocation_Analysis)。

Dim objWord As Word.Application 
Dim wd As Word.Document
Set wd = objWord.Documents.Open("C:\Users\Tim\Desktop\Reference_Text.docx")

ThisDocument.txtLocation_Analysis.Text = '(Want to call a "txtLocation_Analysis_1.text" from wd document)

让我知道这是否有意义-如果可以提供任何帮助,请:)

你试过了吗

ThisDocument.txtLocation_Analysis.Text = "txtLocation_Analysis_1.text" ' A

要么

ThisDocument.txtLocation_Analysis.Text = wd.txtLocation_Analysis_1.Text ' B

抱歉,从措辞上来说,我仍然不清楚,但我认为您希望(A)字符串“ txtLocation_Analysis_1.text”或(B)您打开的文档中另一个文本框的内容出现在ThisDocument的文本框中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM