我已经在我的 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
这确实将文本框中的值插入到变量中,但它不会更新字段,因此我必须手动转到每个字段并更新它。
你能告诉我哪里出错了,以便我可以解决这个问题。
任何和所有的帮助表示赞赏。