VBA control over the ribbon? - excel

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.

Related

Custom Excel Ribbon background colors (like design with tables)

I have used CustomUIEditor to make many excel ribbons. I haven't been able to figure out how to change the background color of custom tabs I make. I'd like to change the background color of my tabs so they are noticeable as custom. I'm thinking of the same method excel uses when you click on a table and the color behind the design tab presents.
Like this:
While VBA can create and modify ribbons (and even add images) it can't change the overall color of the ribbon as seen when the ribbon is not selected.
To change the ribbon color, you need a COM add-in. COM add-ins are different than regular add-ins. Instead of using VBA (which at first glance looks like Visual Basic and is similar to an outdated version of VB), COM add-ins utilize modern Visual Basic or Visual C++.
How to write a COM add-in for Excel is beyond the scope of the question but here are some resources to get you started from Microsoft and Chuck Pearson:
About Excel COM Add-ins
Creating a COM Add-in
Customizing Ribbon Colors

Creating a button on Excel Ribbon to open Userform Window

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.

Hide/Unhide Excel Tab Ribbon

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)

Is it possible to click buttons in the toolbar with macros in Excel 2010?

Is there anyway to make a macro that can click buttons in the tool bars of Excel? I'm using Excel 2010.
Here's how you can record a macro, which will capture your actions.
For Excel 2010:
http://www.dummies.com/how-to/content/how-to-record-a-macro-to-automate-tasks-in-excel-2.html
For Excel 2013:
http://www.dummies.com/how-to/content/how-to-record-new-macros-in-excel-2013.html
In your case, to take this even further, you can do coded UI testing right from Visual Studio. For what you are trying to do, this is even better than only trying to automate a button-click to fire a custom add-in.
Here is a way how you can achieve it with excel 2010:
File->Options->Quick Access Toolbar.
in the "Choose Commands From" list you click "Macros". Select the macro and click add.
If you want change the name of the button you can click "Modify".
Hope it will help you.

Excel Ribbon adding own tabs

Adding ribbon controls seems strightforward enough, but how do I make it so that the extra tab I have only apears when I open a specific workbook.
I want it so that who ever opens the workbook will get the tabs, these tabs and buttons fire of the macros with in this one work book.
do you have to code this dynamicaly or is it possible to tie ribbon customiations to workbooks?
I addition to the link tim provided (which explains in pretty good detail).
If you are more interested in getting somthing simple working, this handy tool will help build custom menus.

Resources