Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50013

Reset Toolbars when a Worksheet is Closed

$
0
0
I have a workbook that is set to open effectively in fullscreen, though I'm simply hiding the ribbon, formula bar, status bar and tabs.

I have a Quit button to allow the user to close the Workbook (this doesn't close the application, only the workbook). I'm using this code to set and reset Excel when the application is opened and closed.

Question
How would I adapt the code so that the Excel toolbars are reset when the worksheet is 'Closed', as well as when the application is exited?

Code:

Private Sub Workbook_Activate()
    On Error Resume Next
    With Application
        .DisplayFormulaBar = False
        .DisplayStatusBar = False
        .CommandBars("Worksheet Menu Bar").Enabled = False
        .ExecuteExcel4Macro "Show.Toolbar(""Ribbon"",False)"
    End With

    With ActiveWindow
        .DisplayWorkbookTabs = False
    End With

End Sub

Private Sub Workbook_Deactivate()
    On Error Resume Next
    With Application
        .DisplayFormulaBar = True
        .DisplayStatusBar = True
        .CommandBars("Worksheet Menu Bar").Enabled = True
        .ExecuteExcel4Macro "Show.Toolbar(""Ribbon"",True)"
    End With

    With ActiveWindow
        .DisplayWorkbookTabs = True
    End With

End Sub


Viewing all articles
Browse latest Browse all 50013

Trending Articles