MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Macro to toggle toolbar

Posted by Dwight on July 10, 2001 6:48 AM

I would like to create a macro to toggle a custom toolbar. If it helps suggest any ideas, I have one for Word (below) which toggles a toolbar called "MF".

If WordBasic.ToolbarState("MF") = -1 Then
WordBasic.ViewToolbars Toolbar:="MF", Hide:=1
WordBasic.ViewToolbars Toolbar:="MF", Show:=1
End If
End Sub

Posted by Barrie Davidson on July 10, 2001 7:38 AM

Hi Dwight, try this macro (you'll need to change the toolbar name to the one you want to toggle).

Sub ToggleToolBar()
' Macro written by Barrie Davidson
If Application.CommandBars("TOOLBAR NAME").Visible = False Then
Application.CommandBars("TOOLBAR NAME").Visible = True
Application.CommandBars("TOOLBAR NAME").Visible = False
End If
End Sub


Posted by Dwight on July 10, 2001 8:32 AM

Super! Thanks, Barrie EOM