DocumentBase.Variables Property

Definition

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

public Microsoft.Office.Interop.Word.Variables Variables { get; }

Property Value

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

Examples

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);
}

Applies to