Variable Interface

Definition

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

public interface class Variable
[System.Runtime.InteropServices.Guid("00020966-0000-0000-C000-000000000046")]
public interface Variable
type Variable = interface
Public Interface Variable
Attributes

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(String, Object) 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.

Properties

Application

Returns a Application object that represents the Microsoft Word application.

Creator

Returns a 32-bit integer that indicates the application in which the specified object was created.

Index

Returns an Integer that represents the position of an item in a collection.

Name

Returns or sets the name of the specified object.

Parent

Returns an object that represents the parent object of the specified object.

Value

Returns or sets the value of the document variable.

Methods

Delete()

Deletes the specified object.

Applies to