Solved

Toggle (show\hide) Excel Ribbon

Posted on 2013-12-05
20
2,629 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

803 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