T
Todd
Hoe do I get a macro to auto open and auto remove? I have
the macros below that I want to add a menu item when I
open the workbook its in and remove it when I close the
workbook. I have been playing with it and can't get it to
work.
Can anyone help?
Todd
Sub MenuBar_Item_Item()
Dim MenuItem As CommandBarControl
MenuBar_Item_Item_Delete
Set MenuItem = Application.CommandBars.FindControl(,
30007) 'Tools menu
If MenuItem Is Nothing Then Exit Sub
With MenuItem.Controls.Add(msoControlButton, 1, , ,
True)
.Caption = "&OpenSupportingDocs"
.OnAction = ThisWorkbook.Name
& "OpenSupportingDocs"
.BeginGroup = True
.Tag = "MenuItemTag"
End With
Set MenuItem = Nothing
End Sub
Sub MenuBar_Item_Item_Delete()
Dim MenuItem As CommandBarControl
Set MenuItem = Application.CommandBars.FindControl
(Tag:="MenuItemTag")
If Not MenuItem Is Nothing Then
MenuItem.Delete
End If
Set MenuItem = Nothing
End Sub
the macros below that I want to add a menu item when I
open the workbook its in and remove it when I close the
workbook. I have been playing with it and can't get it to
work.
Can anyone help?
Todd
Sub MenuBar_Item_Item()
Dim MenuItem As CommandBarControl
MenuBar_Item_Item_Delete
Set MenuItem = Application.CommandBars.FindControl(,
30007) 'Tools menu
If MenuItem Is Nothing Then Exit Sub
With MenuItem.Controls.Add(msoControlButton, 1, , ,
True)
.Caption = "&OpenSupportingDocs"
.OnAction = ThisWorkbook.Name
& "OpenSupportingDocs"
.BeginGroup = True
.Tag = "MenuItemTag"
End With
Set MenuItem = Nothing
End Sub
Sub MenuBar_Item_Item_Delete()
Dim MenuItem As CommandBarControl
Set MenuItem = Application.CommandBars.FindControl
(Tag:="MenuItemTag")
If Not MenuItem Is Nothing Then
MenuItem.Delete
End If
Set MenuItem = Nothing
End Sub