DocumentBase.Variables Property

 

Gets a Variables collection that represents the variables stored in the document.

Namespace:   Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public Variables Variables { get; }

Property Value

Type: Microsoft.Office.Interop.Word.Variables

A Variables collection that represents the variables stored in the document.

The following code example adds a document variable to the document and then displays a message that shows the value of the document variable. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentVariables()
{
    object value = "197";
    object variableName = "BirthYear";
    this.Variables.Add((string)variableName, ref value);
    MessageBox.Show(this.Variables.get_Item(
        ref variableName).Value + 0);
}
Return to top
Show: