2008-10-15 117 views

回答

3

如何使我的word文档中显示:

插入 - >现场>类别:DocumentAutomation->字段名称:DocVariable->域代码按钮 - >然后输入变量的名称。

+2

并只显示他们Alt + F9 – 2016-07-06 17:01:48

6

您可以使用Microsoft Visual Basic for Applications Variables集合来设置和检索Word文档或模板中字符串变量的内容。

另外,可以使用DocVariable字段检索文档变量的值,该值已设置为在Word文档中显示。

来源:How to store and retrieve variables in Word documents

Sub GetSetDocVars() 

Dim fName As String 
fName = "Jeff Smith" 
' Set contents of variable "fName" in a document using a document 
' variable called "FullName". 
ActiveDocument.Variables.Add Name:="FullName", Value:=fName 
' Retrieve the contents of the document variable. 
MsgBox ActiveDocument.Variables("FullName").Value 

End Sub 
+0

但是像这个代码进入什么地方?这是一个Word脚本或什么? – 2016-12-16 14:28:01

相关问题