Solved

Toggle (show\hide) Excel Ribbon

Posted on 2013-12-05
20
2,521 Views
Last Modified: 2014-01-01
Is there a way to do this with Excel 2007+ VBA without resorting to Excel4Macros? And this is not simply View Full Screen. And neither with any ribbon customization add-ins nor packages.
This works but uses Excel4
Sub ToggleRibbon()
    With Application
        .ExecuteExcel4Macro "Show.ToolBar(""Ribbon"", " & (Not (.ExecuteExcel4Macro("Get.ToolBar(7,""Ribbon"")"))) & ")"
    End With
End Sub

Open in new window

End Regards
End Brian
0
Comment
Question by:canesbr
  • 11
  • 8
20 Comments
 
LVL 29

Expert Comment

by:gowflow
ID: 39698657
I don't know what you have against ExecuteExcelMacro4 but

to hide ribbon
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"

to show ribbon
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",true)"


gowflow
0
 
LVL 6

Expert Comment

by:Michael
ID: 39698664
The keyboard shortcut to hide/unhide the ribbon is ctrl+F1, so using SendKeys we get:

Sub ToggleRibbon()
    Application.SendKeys "^{F1}"
End Sub

Open in new window

0
 

Author Comment

by:canesbr
ID: 39698720
Except that CtrlF1 just deals with the Ribbon and not with the QAT and not with the Menu Bar; like the routine I posted. And Sendkeys is, to me, a last resort kluge.
Regards
Brian
0
 

Author Comment

by:canesbr
ID: 39698791
@GoFlow - that is what I posted.
I don't have anything against Excel4Macros per se, I am looking for the VBA equivalent.
Regards
Brian
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39700298
Well there is a large avenue to what you are requesting. With the new Ribbon UI interface starting Excel 2007 you can programmatically do several manipulations with the ribbon. This link give you an overview of what could be achieved in this area
http://www.rondebruin.nl/win/s2/win001.htm

If you are pro in VBA development you could get your way by reading in. otherwise you will need some external help.

So if we excluded Macro4 instruction and Sendkeys, I can lookup if your still interested on how to go about using commandbars which I just started.

Let me know what avenue helps
gowflow
0
 

Author Comment

by:canesbr
ID: 39700863
I am proficient in VBA. Not sure exactly what you are asking me.
Regards
Brian
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39701346
Well not asking anything did the link provided helped you further ? If you don't like the new ribbon avenue then I will look further in the usual vba command to see how to get to what you want. I take this as a personal challenge I do not answer question just for points but always here to learn. So if you still would like to see a vba solution to this then I am in and will dig further.
gowflow
0
 

Author Comment

by:canesbr
ID: 39701877
Yes please dig further into a possible VBA  solution.
Appreciate that
Regards
Brian
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39704388
Sorry but all I found was
.ExecuteExcel4Macro
Application.SendKeys "^{F1}"
RibbonXUI

May I ask why you are looking to get away from the first 2 ? Did you have any problem with these or ... ???

gowflow
0
 

Author Comment

by:canesbr
ID: 39735164
No problem problem - just that
http://blogs.office.com/b/microsoft-excel/archive/2010/02/16/migrating-excel-4-macros-to-vba.aspx
and
http://support.microsoft.com/find-solutions/office/excel-2013/personalization-access/using-macros
Suggests that XLM may become unsupported and recommends that you migrate to VBA.
So my Q is how to do the example in my original post.
Regards
Brian
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 29

Expert Comment

by:gowflow
ID: 39736374
using Excel4Macro ?
gowflow
0
 

Author Comment

by:canesbr
ID: 39736534
Yep - see original post.
Regards
Brian
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39736847
I do not understand.

Your original post had this code
Sub ToggleRibbon()
    With Application
        .ExecuteExcel4Macro "Show.ToolBar(""Ribbon"", " & (Not (.ExecuteExcel4Macro("Get.ToolBar(7,""Ribbon"")"))) & ")"
    End With
End Sub

Open in new window


What else beside this you want ?
gowflow
0
 

Author Comment

by:canesbr
ID: 39736988
VBA Code that does not use Excel4Macros
Regards
Brian
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39737435
well only sendkeys possible would this b ok?
gowflow
0
 

Author Comment

by:canesbr
ID: 39737866
Sendkeys is not preferable.
Regards
Brian
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39737957
well if u had seen my post in ID 39704388 it clearly stated my findings.
Don't know what is your problem with what is obvious and what works which is Macro4. Yes they say it will be dropped but till then it is working. You are trying to look for something that does not exist. So good luck
gowflow
0
 

Author Comment

by:canesbr
ID: 39742627
Always a challenge when someone says "does not exist" or "impossible" in Excel
Regards
Brian
PS. No need for snarkiness @gowflow
0
 

Accepted Solution

by:
canesbr earned 0 total points
ID: 39742708
The following has the same effect and is in fact an acceptable solution.
Application.DisplayFullScreen = Not Application.DisplayFullScreen

So abandon this question as I abandon subscribing to EE.

And good luck to you @gowflow

Regards
Brian
0
 

Author Closing Comment

by:canesbr
ID: 39749632
No acceptable solution from EE.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now