[英]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.