Condividi tramite


Proprietà DocumentBase.Variables

Ottiene un insieme di Variables che rappresenta le variabili archiviate nel documento.

Spazio dei nomi:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

Sintassi

'Dichiarazione
Public ReadOnly Property Variables As Variables
    Get
public Variables Variables { get; }

Valore proprietà

Tipo: Microsoft.Office.Interop.Word.Variables
Insieme di Variables che rappresenta le variabili archiviate nel documento.

Esempi

Nell'esempio di codice riportato di seguito viene illustrato come aggiungere al documento una variabile di documento e come visualizzare un messaggio contenente il valore di tale variabile. Per utilizzare questo esempio, eseguirlo dalla classe ThisDocument in un progetto a livello di documento.

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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

DocumentBase Classe

Spazio dei nomi Microsoft.Office.Tools.Word