Solved

Toggle (show\hide) Excel Ribbon

Posted on 2013-12-05
20
2,658 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

830 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