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)

Syntax

'Declaration
Public ReadOnly Property Variables As Variables
public Variables Variables { get; }

Property Value

Type: Microsoft.Office.Interop.Word.Variables
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 Sub DocumentVariables()
    Dim value As Object = "197" 
    Dim variableName As Object = "BirthYear" 
    Me.Variables.Add(CStr(variableName), value)
    MessageBox.Show(Me.Variables.Item(variableName).Value.ToString() & "0")
End Sub
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);
}

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace