Create the toolbar:
Private Sub AddToolBar()
Dim tBar As CommandBar, NewButton As CommandBarButton
Set tBar = Application.CommandBars.Add
With tBar 'First create the toolbar
.Name = ASTRO_TOOLBAR_NAME
.Visible = True
.Protection = msoBarNoCustomize + msoBarNoResize
.Position = msoBarBottom
End With
'Now set up the buttons
Set NewButton = Application.CommandBars(ASTRO_TOOLBAR_NAME).Controls.Add(Type:=msoControlButton)
With NewButton
.FaceId = 462 '464 is the opposite button
.OnAction = "SimpleView"
.Caption = "Toggle Simple/Full View"
End With
...
The subroutine used by the toolbar button and where the SPECIFIC toolbar button would be changed:
Sub SimpleView()
'Right now this just hides/shows columns
'Need to implement code to change toolbar button
'Dim tBar As CommandBar
'Set tBar = Application.CommandBars
If Columns("A:A").EntireColumn.Hidden Then
Columns("A:A").EntireColumn.Hidden = False
Columns("B:B").EntireColumn.Hidden = False
Columns("I:K").EntireColumn.Hidden = False
'Put code here to change the FaceID = 464
Else
Columns("A:A").EntireColumn.Hidden = True
Columns("B:B").EntireColumn.Hidden = True
Columns("I:K").EntireColumn.Hidden = True
'Put code here to change the FaceID = 462
End If
End Sub
Also, is there are way to give each toolbar button an identification or are they automatically assigned an index number (Item() )? Maybe this would make it easier? I don't know.
Bookmarks