该属性返回一个 Templates 集合,该集合代表所有可用的模板,包括共用模板和附加到打开文档的模板。
expression.Templates
expression 必需。该表达式返回一个 Application 对象。
有关返回集合中单独成员的内容,请参阅返回集合中的对象。
本示例显示 Templates 集合中每个模板的名称。
Count = 1
For Each aTemplate In Templates
MsgBox aTemplate.Name & " is template number " & Count
Count = Count + 1
Next aTemplate
本示例中,如果模板 1 是一个共用模板,则其路径存储在 thePath
变量中。用 ChDir 语句可将存储在 thePath
变量中的路径设为当前文件夹路径。进行更改后,将显示“打开”对话框。
If Templates(1).Type = wdGlobalTemplate Then
thePath = Templates(1).Path
If thePath <> "" Then ChDir thePath
Dialogs(wdDialogFileOpen).Show
End If