Variables Interface


A collection of Variable objects that represent the variables added to a document or template. Document variables are used to preserve macro settings in between macro sessions.

public interface class Variables : System::Collections::IEnumerable
public interface Variables : System.Collections.IEnumerable
type Variables = interface
    interface IEnumerable
Public Interface Variables
Implements IEnumerable


Use the Variables property to return the Variables collection.

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

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 first variable added to the Variables collection is index number 1; the second variable added to the collection is index number 2, and so on.

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



Returns a Application object that represents the Microsoft Word application.


Returns the number of items in the specified collection.


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


Returns an individual object in a collection.


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


Add(String, Object)

Returns a Variable object that represents a variable added to a document.


Applies to