Compartilhar via


DocumentBase.Variables Property

Definition

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

public:
 property Microsoft::Office::Interop::Word::Variables ^ Variables { Microsoft::Office::Interop::Word::Variables ^ get(); };
public Microsoft.Office.Interop.Word.Variables Variables { get; }
member this.Variables : Microsoft.Office.Interop.Word.Variables
Public ReadOnly Property Variables As Variables

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

Applies to