Document.Variables Property (2007 System)

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

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

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property Variables As Variables
'Usage
Dim instance As Document 
Dim value As Variables 

value = instance.Variables
[BrowsableAttribute(false)]
public Variables Variables { get; }
[BrowsableAttribute(false)]
public:
property Variables^ Variables {
    Variables^ get ();
}
public function get Variables () : Variables

Property Value

Type: 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.

This example is for a document-level customization.

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

Document Class

Document Members

Microsoft.Office.Tools.Word Namespace