word中的DOCVARIABLE是什么

发布于 2024-07-07 12:07:05 字数 87 浏览 6 评论 0原文

Microsoft Word 2003 中的 DOCVARIABLE 是什么? 我该如何设置? 如何让它显示在我的Word文档中?

What is a DOCVARIABLE in Microsoft Word 2003? How do I set it? How do I make it display in my Word document?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

故笙诉离歌 2024-07-14 12:07:05

您可以使用 Microsoft Visual Basic for Applications 变量集合来设置和检索 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

You can use the Microsoft Visual Basic for Applications Variables collection to set and retrieve the contents of a string variable in a Word document or template.

Also, you can use the DocVariable field to retrieve the value of a document variable after it has been set to display within a Word document.

Source: 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
泪意 2024-07-14 12:07:05

如何使其显示在我的Word文档中:

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

How do I make it display in my word document:

Insert->Field->Category:DocumentAutomation->Field Names:DocVariable->Field COdes Button-> Then enter the name of the variable.

孤芳又自赏 2024-07-14 12:07:05

我也在寻找这个问题的答案。
创建了一个小脚本来显示所有 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

I was also looking for an answer to this question.
Created a small script to display all ActiveDocument.Variables

Here is it:

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文