什么是DOCVARIABLE字样

joe*_*joe 14 ms-word docvariable

什么是DOCVARIABLEMicrosoft Word 2003?我该如何设置?如何在Word文档中显示它?

Chr*_*rra 7

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

此外,在将文档变量设置为在Word文档中显示后,可以使用DocVariable字段检索文档变量的值.

来源:如何在Word文档中存储和检索变量

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
Run Code Online (Sandbox Code Playgroud)


joe*_*joe 4

如何让它显示在我的word文档中:

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