I really need help, sorry if this question has been already asked.
I have a addin installed on my computer for Excel, which creates a new Ribbon Tab, named "Forecast". This tab is useful only for a specific file, and for the other Excels I want it to be hidden.
I've been thinking on this a lot, and I came to the conclusion that the tab has to be hidden by default and shown by VBA code on opening of the file and hidden on beforeClose event, but I don't really know how to do this.
If anyone else has a better idea and would like to help me, I am very thankful.
Thank you
There is no properties which available via the object model. The Ribbon UI is a static thing, to get any dynamism you need to use callbacks defined in the XML markup.
To get the job done you need to use the getVisible attribute for the tab control. When a document is opened/closed you can check out whether the tab should be displayed or not. If required, you can call the Invalidate or InvalidateControl methods of the IRibbonUI interface to force the application to call your callbacks anew. Thus, you can show or hide a tab dynamically.
Read more about the Fluent UI (aka Ribbon UI) in the following series of articles in MSDN:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
Related
I am working with Excel 2013. I've written several macros in Personal Workbook modules. I've created custom buttons in the ribbon to run those macros and everything works fine. Next day I run Excel and the custom buttons are gone. I tried this many times and the result is always the same. Strange thing is that custom buttons that I have created more than a year ago are there and are never removed
I have done some research and it seems that Excel does this for security issues. Is there a way to bypass this button deletion?
VBA macros is not designed for customizing the Ribbon UI (aka Fluent UI) in Office applications. For current document you may include a custom ribbon UI into the document. For example, the following articles describe how to do that for Word documents, but the approach is common for Excel and Word documents:
OfficeTalk: Customizing the Word 2007 Fluent Ribbon is as Easy as 1-2-3 (Part 2 of 2)
OfficeTalk: Customizing the Word 2007 Fluent Ribbon is as Easy as 1-2-3 (Part 2 of 2)
If you need to distribute your customizations on multiple machines, I'd suggest developing a COM add-in instead, for example, it can be a VSTO add-in. That's what they were invented for. Moreover, you can create a custom UI customizations as a part of the add-in.
Read more about the Fluent UI in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
If you customized the ribbon using file->options, you can see the .officeui file in the below folder, I think this file is not synchronized in your next login, but you can copy to your local, and when it's missing you can copy that officeui file to the %appdata% directory as mentioned below.
%appdata%/Microsoft/office
I recommend you to customize the ribbon in your workbook using CustomUI editor, so that it will retain the customization inside your workbook and not as the separate file (OFFICEUI).
I am working with Excel 2010 but I assume the idea is constant accross all of Office 2010.
I am making an Add in to have some VBA Macros that will work with all of my files and would like to make a ribbon that has buttons bound to these macros. I know how to make a ribbon through Excel Options --> Customize Ribbon but I would like to make one that is shown whenever the Add In is active. This is so I can distribute the Add in with an easy way to run the macros.
Is there a way I can do this? Thanks
UPDATE:
I have read into it and with what I have at my disposal here (Office 2010 and notepad) I am going to have to make the ribbon as an XML document and then put that with my xlam file. I am just not sure on the specifics at this point.
I suppose you are developing a VSTO based add-in. If so, you have two ways to go:
VSTO provides a Ribbon designer which you can use to build the custom UI. See Walkthrough: Creating a Custom Tab by Using the Ribbon Designer to get started quickly.
The other way is to use the Ribbon XML markup for buidling a custom UI (available for all kind of add-ins). See Walkthrough: Creating a Custom Tab by Using the Ribbon Designer for more information.
In general, the Fluent UI ( aka Ribbon UI) is described in the following series of articles in MSDN:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
I ended up doing it by hand based on this answer.
Worked well, just a little tricky working with zipping the Excel Files. Never Unzip the entinre file, just open it with explorer and copy files into it and it worked well!
I have developed a VBA userform interface that allows the user to input values, have it calculate results, and then print them out into the worksheet. I am wondering if there is any possible way that I can have a button on the excel ribbon, say under the "Data" tab for instance, that would elicit the userform interface to open.
Currently the only way I can use the interface is by Developer>>Visual Basic>>Clicking on Userform>>F5. This also limits the userform in that it can only be used in one particular workbook as opposed to many. Or if it was somehow possible, to make it an add-in instead.
Any help is greatly appreciated!
The easiest way to add custom tab and/or button to Ribbon is to use Custom UI Editor Tool for MS Office Ribbon. Follow the links provided in comments to your question too. There you'll find many useful information.
I was adding ustom UI ribbons with tabs, groups an buttons. This works great. Among the makros I have also adden functions to open another excel files.
My problem is that when I return to original excel workbook, the first tab is always activated, instead of the one which was last used (for ex my custom tab).
Is there anyone knowing how can I make Excel remembering which tab I was last using?
For genuine excel tabs this works, only for the custom tab doesn't.
Thank you already for your comments.
OZ
The Application class from the Excel object model provides two events:
WindowActivate - is fired when any workbook window is activated.
WindowDeactivate - is fired when any workbook window is deactivated.
Starting from Office 2010 you can use the ActivateTab method of the IRibbonUI interface. See Ribbon Extensibility in Office 2010: Tab Activation and Auto-Scaling for more information.
So, you can implement the required functionality on your own.
I am in the process of creating a VBA add-in for Excel 2010, and I used the "Custom UI Editor for Microsoft Office" tool to create my own ribbon.
However, I would like to give the user the option to load my add-in without displaying the ribbon, or with different parts of the ribbon visible.
With menus, I know you can completely control them programmatically, but ribbons seem to work differently.
Is there a way in VBA to not load my customUI.xml ribbon tabs on startup?
Is there a way to remove items from (or add items to) these tabs at runtime?
here is a whole slew of help on this subject Awesome Ribbon Help. I think points 2 and 3 are of particular interest to you.