Delete Method Example

This example deletes all custom command bars that aren't visible.

foundFlag = False
delBars = 0
For Each bar In CommandBars
    If (bar.BuiltIn = False) And _
    (bar.Visible = False) Then
        bar.Delete
        foundFlag = True
        delBars = delBars + 1
    End If
Next bar
If Not foundFlag Then
    MsgBox "No command bars have been deleted."
Else
    MsgBox delBars & " custom bar(s) deleted."
End If

This example deletes a custom document property. For this example to run properly, you must have a custom DocumentProperty object named "CustomNumber".

ActiveDocument.CustomDocumentProperties("CustomNumber").Delete