Command Bar (help!)

  • Thread starter Thread starter mikegospo
  • Start date Start date
M

mikegospo

I took this VBA out of the tips and must have used in incorrectly.
Maybe a bad choice for my second one to try. I placed it in the ope
command and it took away the menu bars but I cant get them toggle
back. It shows that way on all of my excel application. Help


Sub ToggleCommandBars()
Dim cbEnabled As Boolean
' get the current commandbar state
cbEnabled = Not Application.CommandBars(1).Enabled
' apply the new state to the Workbook Menu Bar
Application.CommandBars(1).Enabled = cbEnabled
' apply the new state to the Standard toolbar
Application.CommandBars("StandardOPE").Enabled = cbEnabled
' apply the new state to a custom commandbar (the oposite of th
previous two)
Application.CommandBars("MyCustomCommandBar").Enabled = No
cbEnabled
End Su
 
Mike,

It seems to work okay for me (although I don't have toolbars named
StandardOPE and MyCustomCommand, but I tried with Formatting).

If you run it initially (in workbook open?), where are you then trying to
run it for the toggle?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

mikegospo said:
I took this VBA out of the tips and must have used in incorrectly.
Maybe a bad choice for my second one to try. I placed it in the open
command and it took away the menu bars but I cant get them toggled
back. It shows that way on all of my excel application. Help


Sub ToggleCommandBars()
Dim cbEnabled As Boolean
' get the current commandbar state
cbEnabled = Not Application.CommandBars(1).Enabled
' apply the new state to the Workbook Menu Bar
Application.CommandBars(1).Enabled = cbEnabled
' apply the new state to the Standard toolbar
Application.CommandBars("StandardOPE").Enabled = cbEnabled
' apply the new state to a custom commandbar (the oposite of the
previous two)
Application.CommandBars("MyCustomCommandBar").Enabled = Not
cbEnabled
End Sub


------------------------------------------------



~~Now Available: Financial Statements.xls, a step by step guide to
creating financial statements
 
Run it a second time.

--
Regards,
Tom Ogilvy

mikegospo said:
I took this VBA out of the tips and must have used in incorrectly.
Maybe a bad choice for my second one to try. I placed it in the open
command and it took away the menu bars but I cant get them toggled
back. It shows that way on all of my excel application. Help


Sub ToggleCommandBars()
Dim cbEnabled As Boolean
' get the current commandbar state
cbEnabled = Not Application.CommandBars(1).Enabled
' apply the new state to the Workbook Menu Bar
Application.CommandBars(1).Enabled = cbEnabled
' apply the new state to the Standard toolbar
Application.CommandBars("StandardOPE").Enabled = cbEnabled
' apply the new state to a custom commandbar (the oposite of the
previous two)
Application.CommandBars("MyCustomCommandBar").Enabled = Not
cbEnabled
End Sub


------------------------------------------------



~~Now Available: Financial Statements.xls, a step by step guide to
creating financial statements
 
Man you guys are quick, I found a way to fix it in an old forum

Sub test()
Application.CommandBars(1).Enabled = True
End Sub


Now I also found how to make them disappear and reappear

Private Sub Workbook_Activate()
Dim bar As CommandBar
For Each bar In Application.CommandBars
bar.Enabled = False
Next
End Sub

Private Sub Workbook_Deactivate()
Dim bar As CommandBar
For Each bar In Application.CommandBars
bar.Enabled = True
Next
End Sub


Next all I want is a print icon, I will have to research more.

Thanks again
 
Back
Top