OrganizerDelete 方法

       

从文档或模板中删除指定的样式、“自动图文集”词条、工具栏或宏方案项。

expression.OrganizerDelete(Source, Name, Object)

expression   必需。该表达式返回一个 Application 对象。

Source   String 类型,必需。含有需要删除的条目的文档或模板的名称。

Name   String 类型,必需。需要删除的样式、“自动图文集”词条、工具栏或宏的名称。

Object   WdOrganizerObject,必需。需要复制的项目类型。

示例

本示例将从 Normal 模板中删除名为“Custom 1”的工具栏。

Dim cbLoop As CommandBar

For Each cbLoop In CommandBars
    If cbLoop.Name = "Custom 1" Then 
        Application.OrganizerDelete Source:=NormalTemplate.Name, _
            Name:="Custom 1", _
            Object:=wdOrganizerObjectCommandBars
    End If
Next cbLoop

本示例提示用户删除活动文档的相关模板中的每一个“自动图文集”词条。如果用户单击“确定”按钮,则将删除“自动图文集”词条。

Dim atEntry As AutoTextEntry
Dim intResponse As Integer

For Each atEntry In _
        ActiveDocument.AttachedTemplate.AutoTextEntries
    intResponse = _
        MsgBox("Do you want to delete the " & atEntry.Name _
        & " AutoText entry?", vbYesNoCancel)
    If intResponse = vbYes Then
        With ActiveDocument.AttachedTemplate
            Application.OrganizerDelete _
                Source:= .Path & "\" & .Name, _
                Name:=atEntry.Name, _
                Object:=wdOrganizerObjectAutoText
        End With
    ElseIf intResponse = vbCancel Then
        Exit For
    End If
Next atEntry