D
Dennis
I have the following add-in VBA code to create 2 Icons on the "Formatting"
toolbar.
However, when I uncheck the add-in, only one of the icons is deleted from the
Formatting toolbar. How do you get both Icons to be deleted on "BeforeClose"
routine?
TIA
Dennis
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
'Delete Icons on Formatting Toolbar
Application.CommandBars("Formatting").Controls(MenuItemName").Delete
Application.CommandBars("Formatting").Controls("MakeVisible").Deleter
End Sub
Private Sub Workbook_Open()
Dim oCtl1 As CommandBarControl
Dim oCtl2 As CommandBarControl
On Error Resume Next
'just in case they are still on Formatting Toolbar
Application.CommandBars("Formatting").Controls(MenuItemName).Delete
Application.CommandBars("Formatting").Controls("MakeVisible").Delete
On Error GoTo 0
With Application.CommandBars("Formatting")
Set oCtl1 = .Controls.Add(Type:=msoControlButton, temporary:=True)
With oCtl1
.BeginGroup = True
.Caption = "PFLRVar Filter"
.OnAction = MenuItemMacro
.FaceId = 264
End With
Set oCtl2 = .Controls.Add(Type:=msoControlButton, temporary:=True)
With oCtl2
.BeginGroup = True
.Caption = "Reset"
.OnAction = "MakeVisible"
.FaceId = 330
End With
End With
End Sub
toolbar.
However, when I uncheck the add-in, only one of the icons is deleted from the
Formatting toolbar. How do you get both Icons to be deleted on "BeforeClose"
routine?
TIA
Dennis
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
'Delete Icons on Formatting Toolbar
Application.CommandBars("Formatting").Controls(MenuItemName").Delete
Application.CommandBars("Formatting").Controls("MakeVisible").Deleter
End Sub
Private Sub Workbook_Open()
Dim oCtl1 As CommandBarControl
Dim oCtl2 As CommandBarControl
On Error Resume Next
'just in case they are still on Formatting Toolbar
Application.CommandBars("Formatting").Controls(MenuItemName).Delete
Application.CommandBars("Formatting").Controls("MakeVisible").Delete
On Error GoTo 0
With Application.CommandBars("Formatting")
Set oCtl1 = .Controls.Add(Type:=msoControlButton, temporary:=True)
With oCtl1
.BeginGroup = True
.Caption = "PFLRVar Filter"
.OnAction = MenuItemMacro
.FaceId = 264
End With
Set oCtl2 = .Controls.Add(Type:=msoControlButton, temporary:=True)
With oCtl2
.BeginGroup = True
.Caption = "Reset"
.OnAction = "MakeVisible"
.FaceId = 330
End With
End With
End Sub