Workbook Activate/Deactivate VBA to minimise ribbon using SendKey not working as needed

Twaddy006

New Member
Joined
Apr 12, 2014
Messages
26
Hi all

I'm trying to add VBA to hide the ribbon on workbook activation however leave the ribbon tab headings visible, I have it working in that upon opening the workbook in question it minimises the ribbon and leaves the headings visible

The issue is it's then impacting other Excel workbooks when opened by also hiding the ribbon which I don't want

This is my existing code which as I say kind of works but not as needed

Code:
Private Sub Workbook_Activate()
 
If Application.CommandBars("Ribbon").Height > 60 Then
    Application.SendKeys "^{F1}"
End If
 
End Sub
 
Private Sub Workbook_Deactivate()
 
If Application.CommandBars("Ribbon").Height < 60 Then
    Application.SendKeys "^{F1}"
End If
 
End Sub

In the past I've used code for full screen which works and doesn't impact other sheets but it doesn't suit my needs for the new workbook

Code:
Private Sub Workbook_Activate()
 
    Application.ScreenUpdating = False
    Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
    Application.DisplayFormulaBar = False
    Application.DisplayStatusBar = True
    Application.ScreenUpdating = True
 
End Sub
 
Private Sub Workbook_Deactivate()
 
    Application.ScreenUpdating = False
    Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
    Application.DisplayFormulaBar = True
    Application.DisplayStatusBar = True
    Application.ScreenUpdating = True

End Sub

Is the issue because I'm using SendKeys or is there anything else I can add to my code that will ensure it only impacts the workbook in question?

Failing that does anyone have any suggestions on alternative code to minimise the ribbon and leave the ribbon tab headings and save icon etc visible?

Many thanks

Greg
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,215,063
Messages
6,122,927
Members
449,094
Latest member
teemeren

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