Solved

Toggle (show\hide) Excel Ribbon

Posted on 2013-12-05
20
2,761 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 8
20 Comments
 
LVL 31

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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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 31

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 31

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 31

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
 
LVL 31

Expert Comment

by:gowflow
ID: 39736374
using Excel4Macro ?
gowflow
0
 

Author Comment

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

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 31

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 31

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

617 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