T
Tony
I am adding custome toolbars to the workbook on open to
give access to macros. I would like to remove those
toolbars when workbook is closed. How I can do it.
My module looks like:
'********************************
Sub Workbook_Open()
Dim c As CommandBar
Dim cb As CommandBarButton
Dim cp As CommandBarPopup
On Error Resume Next
Set c = Application.CommandBars("Worksheet Menu Bar")
If Not c Is Nothing Then
Set cb = c.Controls.Add(msoControlButton, 2,
temporary:=True)
cb.Style = msoButtonCaption
cb.Caption = "Subtotal"
cb.OnAction = "Sub_total"
Set cb = c.Controls.Add(msoControlButton, 2,
temporary:=True)
cb.Style = msoButtonCaption
cb.Caption = "Insert"
cb.OnAction = "Insert"
Set cb = c.Controls.Add(msoControlButton, 2,
temporary:=True)
cb.Style = msoButtonCaption
cb.Caption = "Update"
cb.OnAction = "Update"
Set cb = c.Controls.Add(msoControlButton, 2,
temporary:=True)
cb.Style = msoButtonCaption
cb.Caption = "Print Master Summary"
cb.OnAction = "PrintMasterSummary"
Set cb = c.Controls.Add(msoControlButton, 2,
temporary:=True)
cb.Style = msoButtonCaption
cb.Caption = "Print Summary"
cb.OnAction = "PrintSummary"
Set cb = c.Controls.Add(msoControlButton, 2,
temporary:=True)
cb.Style = msoButtonCaption
cb.Caption = "Print Entries"
cb.OnAction = "PrintEntries"
End If
End Sub
'************************************
Sub Workbook_BeforeClose(Cancel As Boolean)
?????
End Sub
'************************************
Thanks for advice.
Tony
give access to macros. I would like to remove those
toolbars when workbook is closed. How I can do it.
My module looks like:
'********************************
Sub Workbook_Open()
Dim c As CommandBar
Dim cb As CommandBarButton
Dim cp As CommandBarPopup
On Error Resume Next
Set c = Application.CommandBars("Worksheet Menu Bar")
If Not c Is Nothing Then
Set cb = c.Controls.Add(msoControlButton, 2,
temporary:=True)
cb.Style = msoButtonCaption
cb.Caption = "Subtotal"
cb.OnAction = "Sub_total"
Set cb = c.Controls.Add(msoControlButton, 2,
temporary:=True)
cb.Style = msoButtonCaption
cb.Caption = "Insert"
cb.OnAction = "Insert"
Set cb = c.Controls.Add(msoControlButton, 2,
temporary:=True)
cb.Style = msoButtonCaption
cb.Caption = "Update"
cb.OnAction = "Update"
Set cb = c.Controls.Add(msoControlButton, 2,
temporary:=True)
cb.Style = msoButtonCaption
cb.Caption = "Print Master Summary"
cb.OnAction = "PrintMasterSummary"
Set cb = c.Controls.Add(msoControlButton, 2,
temporary:=True)
cb.Style = msoButtonCaption
cb.Caption = "Print Summary"
cb.OnAction = "PrintSummary"
Set cb = c.Controls.Add(msoControlButton, 2,
temporary:=True)
cb.Style = msoButtonCaption
cb.Caption = "Print Entries"
cb.OnAction = "PrintEntries"
End If
End Sub
'************************************
Sub Workbook_BeforeClose(Cancel As Boolean)
?????
End Sub
'************************************
Thanks for advice.
Tony