Variables 接口

定义

Variable代表添加到文档或模板中的变量的对象的集合。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
[System.Runtime.InteropServices.Guid("00020965-0000-0000-C000-000000000046")]
public interface Variables : System.Collections.IEnumerable
type Variables = interface
    interface IEnumerable
Public Interface Variables
Implements IEnumerable
属性
实现

注解

使用 Variables 属性返回Variables集合。Use the Variables property to return the Variables collection.

使用 Add(String, Object) 方法可向文档中添加变量。Use the Add(String, Object) method to add a variable to a document.

如果您尝试在 Variables 集合中添加一个文档变量已经存在的名称,则会导致出错。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.

使用变量index ),其中 index 是文档变量名称或索引号,返回单个变量对象。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. 第一个加入 Variables 集合的变量为索引号为 1;第二个添加到集合的变量为索引号为 2,依次类推。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.

若要将变量添加到模板,请使用方法以文档的形式打开模板 OpenAsDocument()To add a variable to a template, open the template as a document by using the OpenAsDocument() method.

属性

Application

返回一个 Application 代表 Microsoft Word 应用程序的对象。Returns a Application object that represents the Microsoft Word application.

Count

返回指定集合中的项目数。Returns the number of items in the specified collection.

Creator

返回一个 32 位整数,它指示在其中创建指定的对象的应用程序。Returns a 32-bit integer that indicates the application in which the specified object was created.

Item[Object]

返回集合中的单个对象。Returns an individual object in a collection.

Parent

返回一个对象,代表指定对象的父对象。Returns an object that represents the parent object of the specified object.

方法

Add(String, Object)

返回一个 Variable 对象,表示添加到文档中的变量。Returns a Variable object that represents a variable added to a document.

GetEnumerator()

适用于