When AddIn Unchecked Delete It's Tools Menu Item How?

D

Dennis

I have an Add-In xla that has created a menu Item on the Tools Menu with the
following code in the xla project.

Private Sub Workbook_Open()
.......
Set NewItem = Application.CommandBars(1) _
.Controls("tools").Controls.Add
NewItem.Caption = MenuItemName
NewItem.OnAction = MenuItemMacro
NewItem.BeginGroup = True
.....
end sub

If the Add-In is subsequently unchecked in Tools->Add-Ins

How do I delete the menu Item from the Tools Menu? Just unchecking just left
the menu item on the tools menu creating an error when clicked.

If Tried

Private Sub Workbook_Close()
Application.CommandBars(1) _
.Controls("Tools").Controls(MenuItemName).Delete
End Sub

but this didn't work.
 
C

Celtic_Avenger

try by putting the same VBA in the before close action in the mai
Workbook code.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars(1) _
.Controls("Tools").Controls(MenuItemName).Delete
End Su
 
Top