Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Toggle (show\hide) Excel Ribbon

Posted on 2013-12-05
20
Medium Priority
?
2,833 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
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.

721 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