What is the best way to have a bookmark of commands for MS office application (mainly excel, project). For example, I need to group some of the most used reports in MS project or buttons to invoke a macro. Something like custom ribbon (with a tab and action buttons) would do, but the problem is it affect all the files. I want to do per file basis.
Ribbon customization in Excel can be done on a per file basis in 2007 and 2010. The excel file container is a .zip file that contains an XML file that details any ribbon customization.
You can get the basics from this msdn article:
Display and Hide Tabs, Groups, and Controls on the Microsoft Office Ribbon
It's written by Ron de Bruin, his website is http://www.rondebruin.nl/tips.htm which has some additional resources for ribbon customization.
For re purposing existing excel commands the structure is fairly simple and should be readily achievable for your purpose.
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 have noticed that when users have the Windows file explorer preview pane enabled and then view a Word or Excel file, that my VSTO addin is started. Further my addin starts again when the user double clicks on a excel or word file.
What properties in Word and Excel do I need to check at startup to know that it is the preview pane?
For people's reference I did find a discussion on this for Powerpoint in this SO question.
When Word and excel are started by the file explorer as a preview then what I have found is that you can check for a commandlinearg of -Embedding
Environment.GetCommandLineArgs().Contains("-Embedding"))
Detecting Automation of Excel is where I found this answer. This question is about automation.
Also when a user embeds for example Excel in Word and then edits the embedded Excel the VSTO addin will start multiple times. You can check for the -Embedding arg for this as well.
Typically the ribbon bar is not visible when Office applications are used for rendering documents in the Windows explorer. You may use the following code to check that:
Application.CommandBars("Ribbon").Visible
I'm trying to control Outlook via Excel by VBA ofc.
My Excel code creates and XML that adds button to Message Ribbon.
The button's job is to save email to specific location given by Excel.
I cant run Excel macro from Outlook macro because you cant access VB Project of Outlook. It needs to be provided for couple of persons and this is hard to deploy and control. So I thought maybe I can capture click event of that button from excel. I've seen examples to capture Reply button but nothing else.
I'm looking for place in Outlook object where this information might be stored. And any help with that, different approaches are welcome as well.
It looks like you need to develop a COM add-in instead of VBA macro. First of all, you can't modify the Ribbon UI in Outlook from VBA macros as you do it in Excel. Second, VBA macros are not designed for distributing them on multiple machines. That is what COM add-ins were invented for. See Walkthrough: Create your first VSTO Add-in for Outlook to get started quickly.
The following articles provide instructions on how to create a custom ribbon UI:
Walkthrough: Create a custom tab by using the Ribbon Designer
Walkthrough: Create a custom tab by using Ribbon XML
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 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.