[英]How to copy textbox value in a word document into a textbox in a different word document with VBA (MS Word 2003)
Hopefully an easy question. 希望这是一个简单的问题。
I have two word documents (MS Word 2003), each document has a text box object. 我有两个Word文档(MS Word 2003),每个文档都有一个文本框对象。 Upon pressing a command button, I want the text that is in the text box in one document ("Reference_Text.docx") to go into the text box of another document.
按下命令按钮后,我希望一个文档(“ Reference_Text.docx”)的文本框中的文本进入另一文档的文本框中。
Below shows the code I am trying to use in an event when the command button is pushed. 下面显示了我在按下命令按钮时试图在事件中使用的代码。 I am trying to have the text box (txtLocation_Analysis) populated with the text that is in "txtLocation_Analysis_1", which is in the Reference_Text.docx file.
我正在尝试使用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)
Let me know if this makes sense - and if any help can be provided please :) 让我知道这是否有意义-如果可以提供任何帮助,请:)
Hugh 休
Did you try 你试过了吗
ThisDocument.txtLocation_Analysis.Text = "txtLocation_Analysis_1.text" ' A
or 要么
ThisDocument.txtLocation_Analysis.Text = wd.txtLocation_Analysis_1.Text ' B
Sorry, from the wording it's still not clear to me but I think you want either (A) the string "txtLocation_Analysis_1.text" or (B) the contents of another textbox in the document you opened, appear in the textbox in ThisDocument. 抱歉,从措辞上来说,我仍然不清楚,但我认为您希望(A)字符串“ txtLocation_Analysis_1.text”或(B)您打开的文档中另一个文本框的内容出现在ThisDocument的文本框中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.