VBA problem with CommandBars
When I want to clear off a custom CommandBarControl (like when the workbook
is closed), I use:
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("xxx").Delete
On Error GoTo 0
Its simpler than searching.
--
Les Torchia-Wells
"zuEgg" wrote:
Hi.
I'm having problems writing a macro that creates a custom
CommandBarControl. I have to check if the CommandBarControl is empty
and then delete it.
Here is the code of what i'm doing:
Dim cbpop As CommandBarControl
Dim cbctl As CommandBarControl
Dim bExists As Boolean
bExists = False
For Each cbpop In Application.CommandBars("Worksheet Menu
Bar").Controls
If cbpop.Caption = "xxx" Then
' if the CommandBarControl is empty.........
Application.CommandBars("Worksheet Menu
Bar").Controls("xxx").Delete
End If
Next
I've been searching for long but i've not found any hint for solving
the problem.
Thanks,
Massimo
|