DOCVARIABLE
Microsoft Word 2003中的 a 是什么?我该如何设置?如何让它显示在我的 Word 文档中?
joe
问问题
36402 次
3 回答
7
您可以使用 Microsoft Visual Basic for Applications 变量集合来设置和检索 Word 文档或模板中字符串变量的内容。
此外,您可以使用 DocVariable 字段来检索已设置为在 Word 文档中显示的文档变量的值。
资料来源:如何在 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
于 2008-10-15T15:38:48.023 回答
4
如何让它显示在我的word文档中:
Insert->Field->Category:DocumentAutomation->Field Names:DocVariable->Field COdes Button->然后输入变量名。
于 2008-10-15T16:07:34.673 回答
0
我也在寻找这个问题的答案。创建了一个小脚本来显示所有 ActiveDocument.Variables
就这个:
Sub GetVariables()
' Declaration of output variavle, which is a string
Dim output As String
output = ""
For Each Variable In ActiveDocument.Variables
' & is used for string concatenation.
output = output & Variable.Name & " = " & Variable & vbNewLine
Next
MsgBox output
End Sub
于 2019-07-23T08:59:06.873 回答