【发布时间】:2021-04-11 20:59:25
【问题描述】:
我已经在我的 word 模板中创建了 DocVariables,并且正在使用 UserForm 来允许用户输入来填充这些变量。
这是我一直在使用的代码:
Private Sub CommandButton1_Click()
Dim ReportTitle, reportSub As String
ReportTitle = Me.textBox1.Value
reportSub = Me.textBox2.Value
ActiveDocument.Variables("Report Title").Value = ReportTitle
ActiveDocument.Variables("Sub-Title").Value = reportSub
ActiveDocument.Fields.Update
Me.Repaint
End Sub
这确实将文本框中的值插入到变量中,但不会更新字段,因此我必须手动转到每个字段并进行更新。
请告诉我哪里出了问题,以便我解决这个问题。
感谢所有帮助。
【问题讨论】:
-
你看起来不是很努力。一个简单的 Bing/Google 搜索就会给你答案,你也可以在这里找到:stackoverflow.com/questions/33733113/…
标签: vba ms-word docvariable