DocumentBase.Variables Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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