If I have a IRibbonUI object stored can I use it to add controls to the ribbon using VBA code? - excel

Given that I have stored the IRibbonUI object onLoad, can I use that to modify the CustomUI.xml in my stub .xlam ribbon? If not, can it be used to add tabs, controls, etc. via VBA code?

The IRibbonUI object can only invalidate, i.e. reset the caches, on already defined controls and switch tabs on the ribbon. However, you can use the invalidation to trigger callbacks which show/hide already-defined controls by using the getVisible property, for example see this answer:
Hide individual custom ribbon buttons.
Or change their images as per:
Excel Ribbon Dropdown background color.
The Ribbon XML is immutable for the life of the related COM add-in. If you want to specify a completely new Ribbon XML, you need another master/controller addin to disconnect and re-connect the COM addin which declared the Ribbon. This is a bit more complicated, so hopefully you can achieve what you need with the getVisible functionality.

Thank you for that confirmation. I saw that this can be done in MS Project but, sadly, not in Excel.
All of the other items you mentioned regarding callbacks are in place and working well. Hide/show, changing labels, etc. but always on pre-defined controls.

Related

Is there a way to add custom icons to a ribbon using VBA through a callback to the UI Editor?

I am making a ribbon for my office. I have programmed all the macros already, except for the icons.
In the UI Editor, I have set everything to be done via a callback in VBA.
I have loaded all the icons using the MS Excel stock icons, however I have 9 icons that have to be added as they are not part of the excel standards.
I can't use different icons as the buttons in the ribbon paste the pictures that I need to display as the icons.
In the UI editor, I have set it up that all the buttons use "getimage=getimage" and have programmed a callback in VBA.
I don't seem to be able to change the 9 specific buttons to "image=pic1" and use the icons (pic1-pic9) I have loaded in the UI Editor.
When I try to do that, I get an error saying "the 'Image' attribute is not declared"
So now I am looking for a workaround in VBA.
Current callback code for a standard Icon:
Case "eButton03": RibbonImage = "ObjectPictureFill"
I need the code above to pull in a picture instead of using the standard icon.
let's say the picture is saved in C:\Pic\Pic1.png
Use this list: https://bert-toolkit.com/imagemso-list.html
You can also use or create custom images, add your picture "yourpic.png" via Excel's "Insert Icons" option in the Custom UI Editor.
Use the code
image="yourpic"
To use your picture as a custom icon.

Options of message box in Excel

We would like to change the font, color and size of the text displayed in message boxes.
Can/how do you VBA this?
Nothing tried, we are not finding any help in online manuals, including the Microsoft help site.
We would like to make the message box big, bold and loud.
Easy answer: You can't.
That's why you can't find anything about it in the official documentation of the MsgBox function.
A workaround can be to create your own UserForm where you are free in how to style it.
Add a UserForm in your workbook's code module, and configure it with as many Label and CommandButton controls as needed.
If the label text will be static, you can configure these all through the Properties window in the IDE:
Labels, Command Buttons, etc., are accessible Controls on the UserForm, and can be altered dynamically during runtime if needed, e.g., during the form's Initialize or Activate or any other event handlers. Controls on the form can even alter other controls, for example you could leverage the command button's Click event handler to modify the text associated with Label1 control, etc.
You can even add (or remove) controls (labels and such) dynamically, too, and fully control their appearance/formatting/etc.

Show hidden ribbon elements

In previous iterations, there were some ribbon buttons and tabs that were hidden via the HideCustomAction in the customizations.xml. Now the client is requesting that some of those elements be shown. I've exported the solution, and removed the hide custom action. The tab is still not shown even though the HideCustomAction was removed. Are there any additional steps needed to be taken to re-show the hidden elements?
The best thing would be to have the developer of the managed solution update the solution with the proper ribbon configuration. That's the supported approach.
If that isn't an option, you could look to recreate the CustomAction buttons in a solution with different IDs but the same actions. Basically creating two sets of the buttons.

How to set icon size in Outlook 2010 add in c#

I develope an outlook 2010 add-in,
I have Office.CommandBars cmdBars that holds Office.CommandBarButton,
I set the buttonTemp_Dial.Style = Office.MsoButtonStyle.msoButtonIconAndCaption
and buttonTemp_Dial.Picture have a reference to icon pic.
The icon in add in is small how can I change it to big Icon?
the add-in is in separate tab in Outlook, is there a way to put the add in to the "Home" tab?
If you use the old CommandBars based API, your button will appear on the Addins tab, which is probably not something that you want.
Your add-in (on the low level) needs to implement the IRibbonExtensibility interface and return your customization as XML - see http://msdn.microsoft.com/en-us/library/office/bb226712(v=office.12).aspx

Appropriateness of use regarding ribbons and menu's in sharepoint 2010

So with the new Ribbon on top of the SharePoint 2010 page we have an office like feel to working with SharePoint pages. Customization of this ribbon is great, adding your own functionality augmenting what Microsoft provides out of the box. My question is this though, when is it appropriate to use ribbon customization vs an item menu option (i.e. the callout menu on a particular item).
Are there best practices around this? What do you do?
They share a lot of the same options. The ribbon is focused on working with the entire list or library, but still has options pop up when you click on an item that are targeted at that one item. The call-out on a single item is always focused on options for just that item.
So I would say if your looking to do something with an entire list or library, put it in the ribbon. If it is going to be an option specifically tied to one item at a time, put it in the call-out menu, but also try to make it show up in the ribbon if someone doesn't look at the call-out menu.
But that's just my opinion and I haven't had any experience putting custom functionality into either sections.

Resources