Hide and bring back Ribbon

Jose5847

New Member
Joined
Nov 26, 2016
Messages
6
Hi all, so I am wondering if anybody can help me fix a problem. I have a sheet that when "workbook_open" its suppose to hide ribbon, headings, formula bar, tabs etc.. Which it does perfectly. The problem is that it is not going back to normal when I close. Below is the workbook_close VBA. Any help would be greatly appreciate it. And while I am at it, is there a way to hide all of the mentioned only for the workbook instead of all other excels opened while this one is open?

Code:
Sub workbook_Close()

   
    Worksheets("PastedReport").Visible = xlSheetVisible
    Worksheets("PastedReport").Cells.ClearContents
    Worksheets("PastedReport").Visible = xlSheetVeryHidden
    Worksheets("Sheet2").Visible = xlSheetVeryHidden
    Worksheets("Sheet3").Visible = xlSheetVeryHidden
    Sheets("Home").Visible = True
    Sheets("Home").Select
   
    ThisWorkbook.Saved = False
    Application.ScreenUpdating = False
    Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
    Application.DisplayStatusBar = True
    ActiveWindow.DisplayWorkbookTabs = True
    Application.DisplayFormulaBar = True
    Application.ScreenUpdating = True
   
   
End Sub
 
Last edited by a moderator:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi there. Just a wild guess, but it may be that because you do nothing else after setting screenupdating back on, that excel 'loses' the changes? You could try putting something like
VBA Code:
Sheets("Home").Range("A1").Select
at the end (just before the end sub).
For your other question, unfortunately the scope of the changes is at Application level, so is the same for all workbooks open in this instance of excel. One way to achieve roughly what you want would be to open this workbook in a separate instance of the excel program. You can do this by starting excel from the Programs list, and then opening your workbook in this 'new' excel.
 
Upvote 0
JMACleary, thank you for the response. I tried it but it did not work. Then I noticed that it actually does work but I need to close all excel files before if can go back to normal. I dont like it but, for now, its ok.

Thanks again for the feedback and help!
 
Upvote 0
You're welcome, even though I didn't really solve it. A couple of last ideas, you could try leaving out the
VBA Code:
Application.ScreenUpdating = False
to see if that works, or try
VBA Code:
Application.CalculateFull
at the end (I don't expect this to work, since it recalculates data rather than settings, but you never know).
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,893
Members
449,194
Latest member
JayEggleton

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