Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a DOCVARIABLE in word

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

like image 697
joe Avatar asked Oct 15 '08 15:10

joe


People also ask

What are the 5 views in Microsoft Word?

The different document views are: “Read Mode,” “Print Layout,” “Web Layout,” “Outline,” and “Draft.” If you use Word for Office 365 or Office 2019 for Mac, you will also see a “Focus Mode” button in the Status Bar and in the “Immersive” button group on the “View” tab in the Ribbon.


2 Answers

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
like image 103
Chris Serra Avatar answered Oct 06 '22 10:10

Chris Serra


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.

like image 4
joe Avatar answered Oct 06 '22 10:10

joe