hide / unhide toolbars

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,604
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I recorded this simple macro to hide certain toolbars and placed it into the This Workbook part of vb
Code:
Private Sub workbook_open()

Application.CommandBars("Standard").Visible = False
    Application.CommandBars("Formatting").Visible = False
    Application.CommandBars("Drawing").Visible = False
            data.Show

End Sub

question is, on workbook close I want them all to be shown again thus leaving excel view 'normal'

I thought by changing the =False values to =True would work
Code:
Private Sub workbook_close()
Application.CommandBars("Standard").Visible = True
    Application.CommandBars("Formatting").Visible = True
    Application.CommandBars("Drawing").Visible = True
   End Sub

but when the workbook is closed and a normal empty MS Excel workbook is opened, all the previously hidden toolbars still are.

Any ideas how to show the hidden toolbars again on closing my workbook|?

thanks
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
The correct method would be the 'BeforeClose' event:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
However what happens when somebody wants to use another open workbook? Your better off using something like this:

Code:
Private Sub Workbook_Activate()
Application.CommandBars("Standard").Visible = False
Application.CommandBars("Formatting").Visible = False
Application.CommandBars("Drawing").Visible = False

End Sub

Private Sub Workbook_Deactivate()
Application.CommandBars("Standard").Visible = True
Application.CommandBars("Formatting").Visible = True
Application.CommandBars("Drawing").Visible = True

End Sub
HTH
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,408
Members
452,912
Latest member
alicemil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top