OrganizerDelete Method

Microsoft Word Visual Basic

Deletes the specified style, AutoText entry, toolbar, or macro project item from a document or template.

expression.OrganizerDelete(Source, Name, Object)

expression    Required. An expression that returns an Application object.

Source    Required String. The file name of the document or template that contains the item you want to delete.

Name    Required String. The name of the style, AutoText entry, toolbar, or macro you want to delete.

Object   Required WdOrganizerObject. The kind of item you want to copy.

WdOrganizerObject can be one of these WdOrganizerObject constants.
wdOrganizerObjectAutoText
wdOrganizerObjectCommandBars
wdOrganizerObjectProjectItems
wdOrganizerObjectStyles

Example

This example deletes the toolbar named "Custom 1" from the Normal template.

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
		

This example prompts the user to delete each AutoText entry in the template attached to the active document. If the user clicks the Yes button, the AutoText entries are deleted.

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