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.

Namespace: Microsoft.Office.Interop.Word
Assembly: Microsoft.Office.Interop.Word (in

Public Class ariablesImplementation
	Implements Variables
End Class
Dim ariablesImplementation1 As New ariablesImplementation()

public interface Variables : IEnumerable
public interface Variables implements IEnumerable
public interface Variables implements IEnumerable

Use the Variables property to return the Variables collection.

Use the Add 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.

Development Platforms

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

Target Platforms