Share via


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 Microsoft.Office.Interop.Word.dll)

Syntax

'Declaration
<GuidAttribute("00020965-0000-0000-C000-000000000046")> _
Public Interface Variables _
    Inherits IEnumerable
'Usage
Dim instance As Variables
[GuidAttribute("00020965-0000-0000-C000-000000000046")]
public interface Variables : IEnumerable

Remarks

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.

See Also

Reference

Variables Members

Microsoft.Office.Interop.Word Namespace