Delete Method
Applies To
CommandBar object, CommandBarButton object, CommandBarComboBox object, CommandBarControl object, CommandBarPopup object, DocumentProperty object, FileFind object.
Description
Deletes the specified object from the collection it's contained in.
Syntax 1
expression.Delete
Syntax 2
expression.Delete(Temporary)
Syntax 3
expression.Delete(BstrQueryName)
expression Required. An expression that returns a CommandBar or DocumentProperty object (Syntax 1), a CommandBarControl object (Syntax 2), or a FileFind object (Syntax 3).
Temporary Optional Variant. True to delete the control for the current session. The application will display the control again in the next session.
BstrQueryName Required String. A string containing up to 31 characters that indicates the name of the saved search criterion to be deleted.
Remarks
You cannot delete a built-in document property.
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
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. You must pass a DocumentProperty object to the procedure.
Sub DeleteCustomDocumentProperty(dp As DocumentProperty)
dp.Delete
End Sub