Variable Interface 

Represents a variable stored as part of a document. Document variables are used to preserve macro settings in between macro sessions.

Namespace: Microsoft.Office.Interop.Word
Assembly: Microsoft.Office.Interop.Word (in microsoft.office.interop.word.dll)

Usage

Public Class ariableImplementation
    Implements Variable
End Class
Dim ariableImplementation1 As New ariableImplementation()

Syntax

Public Interface Variable
public interface Variable
public interface class Variable
public interface Variable
public interface Variable

Remarks

The Variable object is a member of the Variables collection. The Variables collection includes all the document variables in a document or template.

Use Variables(index), where index is the document variable name or the index number, to return a single Variable object.

The index number represents the position of the document variable in the Variables collection. The last variable added to the Variables collection is index number 1; the second-to-last variable added to the collection is index number 2, and so on.

Use the Add of the Variables collection method to add a variable to a document.

If you try to add a document variable with a name that already exists in the Variables collection, an error occurs. To avoid this error, you can enumerate the collection before adding any new variables.

Document variables are invisible to the user unless a DOCVARIABLE field is inserted with the appropriate variable name.

To add a document variable to a template, open the template as a document by using the OpenAsDocument method.

Platforms

Development Platforms

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, and Windows 2000

Target Platforms

See Also

Reference

Microsoft.Office.Interop.Word Namespace

Other Resources

Variable Members