J
jfitzpat
I used the code below to create a floating toolbar for my spreadsheet. I had
previously tried a manual method of creating a custom toolbar but it did not
work. The new toolbar works but the old one still comes up when the users
open the file. I have deleted it and resaved the file many times but this
old toolbar seems to still be connect to the file -- how can I get rid of it?
Option Explicit
Public Const ToolBarName As String = "MyToolbarSR"
Sub Autpen()
Call CreateMenubar
End Sub
Sub Auto_Close()
Call RemoveMenubar
End Sub
Sub RemoveMenubar()
On Error Resume Next
Application.CommandBars(ToolBarName).Delete
On Error GoTo 0
End Sub
Sub CreateMenubar()
Dim iCtr As Long
Dim MacNames As Variant
Dim CapNamess As Variant
Dim TipText As Variant
Call RemoveMenubar
MacNames = Array("Spell_Check")
CapNamess = Array("SR Spell Check")
TipText = Array("Use this button to Spell Check Status Report")
With Application.CommandBars.Add
.Name = ToolBarName
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating
For iCtr = LBound(MacNames) To UBound(MacNames)
With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & MacNames(iCtr)
.Caption = CapNamess(iCtr)
.Style = msoButtonIconAndCaption
.FaceId = 71 + iCtr
.TooltipText = TipText(iCtr)
End With
Next iCtr
End With
End Sub
previously tried a manual method of creating a custom toolbar but it did not
work. The new toolbar works but the old one still comes up when the users
open the file. I have deleted it and resaved the file many times but this
old toolbar seems to still be connect to the file -- how can I get rid of it?
Option Explicit
Public Const ToolBarName As String = "MyToolbarSR"
Sub Autpen()
Call CreateMenubar
End Sub
Sub Auto_Close()
Call RemoveMenubar
End Sub
Sub RemoveMenubar()
On Error Resume Next
Application.CommandBars(ToolBarName).Delete
On Error GoTo 0
End Sub
Sub CreateMenubar()
Dim iCtr As Long
Dim MacNames As Variant
Dim CapNamess As Variant
Dim TipText As Variant
Call RemoveMenubar
MacNames = Array("Spell_Check")
CapNamess = Array("SR Spell Check")
TipText = Array("Use this button to Spell Check Status Report")
With Application.CommandBars.Add
.Name = ToolBarName
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating
For iCtr = LBound(MacNames) To UBound(MacNames)
With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & MacNames(iCtr)
.Caption = CapNamess(iCtr)
.Style = msoButtonIconAndCaption
.FaceId = 71 + iCtr
.TooltipText = TipText(iCtr)
End With
Next iCtr
End With
End Sub