I've been trying to manipulate Outlook Ribbon, namely QAT icons, from VBA editor.
Found references to IRibbonExtensibility, which is actually recognized in class modules:
Implements IRibbonExtensibility
Public Function IRibbonExtensibility_GetCustomUI(ByVal RibbonID As String) As String
'Must return XML
End Function
However, I can't get this interface instantiated:
Adding this code in ThisOutlookSession cause Outlook startup error.
Instantiating class modules with this code render IRibbonExtensability member as Nothing.
Is this only available for COM Addins? Any other direction?
Yes, in case of Outlook the Fluent UI customizations are available through COM add-ins only.
Read more about the Fluent UI (aka Ribbon 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)
Related
I'm trying to add customUI onload automatically inside PowerPoint "RibbonX", but I can't find any way to use VBA code for that!
Can anyone please help me with that?
The onLoad callback is called only when it is declared in the Ribbon XML markup. The customUI element contains the corresponding attribute for that.
<customUI … OnLoad="MyAddinInitialize" …>
Read more about the Fluent UI (aka Ribbon 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)
I am looking for a solution to disable the button "Slide Master" in PowerPoint when someone opens a specific template / PowerPoint file. The reason is to stop basic user to change layouts (basically the master).
The macro I guess, must also allow that specific users (Power Users) are able to enable that button by inserting a passwort. I have nevery programmed anything around the ribbon. Can someone help me with this task?
You can try repurposing the built-in control. See Temporarily Repurpose Commands on the Office Fluent Ribbon for more information.
Also you may define the getEnabled callback for the button where you can manage the enabled state dynamically. The signature of the getEnabled callback looks in the following way:
C#: bool GetEnabled(IRibbonControl control)
VBA: Sub GetEnabled(control As IRibbonControl, ByRef enabled)
C++: HRESULT GetEnabled([in] IRibbonControl *pControl, [out, retval] VARIANT_BOOL *pvarfEnabled)
Visual Basic: Function GetEnabled(control as IRibbonControl) As Boolean
The Fluent UI (aka Ribbon UI) is described in depth 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)
I can use custum ui editor for Excel and Word VBA projects to add custom buttons on the ribbon with XML.
I have an Outlook-project (VBAProject.otm) and would like to do the same thing, to add buttons to the ribbon so when I'm deploying the custom buttons move with it.
I don't wont to use VSTO, only VBA.
Any suggestions?
Unlike other Office applications, in Outlook VBA macros can't be used for customizing the ribbon UI. You need to develop a COM add-in (for example, a VSTO based one). Take a look at the following articles:
Walkthrough: Creating a Custom Tab by Using the Ribbon Designer
Walkthrough: Creating a Custom Tab by Using Ribbon XML
The Fluent UI (aka Ribbon UI) is described in depth 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)
Full Credit to This Site
Is it possible to take a pre-existing button from the ribbon, Shape Fill from the Shape Styles category for example, and display it in a VBA userform?
My add-in manages a large number of shapes, and I would like to allow the user to style those shapes based on the category that they are in in the add-in.
I have read that a color dialog does not exist for us to use in VBA, so I'm trying to think of a way to work around that. Recreating all of the fill, outline, and effects menus seems like too much, there has to be a better way.
No, built-in ribbon controls can be used on the ribbon only. As a workaround you may consider using any ActiveX custom controls on your form.
Also you may consider creating a custom UI on the ribbon. In that case you will be able to add built-in ribbon controls to your own tab by specifying its idMso value. The full list of control IDs can be found in the following documents:
Office 2010 Help Files: Office Fluent User Interface Control Identifiers
Office 2013 Help Files: Office Fluent User Interface Control Identifiers
Office 2016 Help Files: Office Fluent User Interface Control Identifiers
Read more about the Fluent UI (aka Ribbon 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)
Situation:
Users have an existing custom ribbon that is added via a .PPAM (combination of VBA macros and Ribbon customization XML).
We want to add a group to that custom ribbon via our managed COM add-in
For custom ribbons from other managed COM add-ins this is feasible via the xmlns:foo="bar" & idQ that can be extracted from the customUI Link
Complication:
Custom Ribbons from non-managed add-ins seem to have no xmlns namespace, they do not show up in the customUI
Even via PowerPoint/Office the user can not customize those ribbons.
Any idea how we could achieve adding buttons?
We can request changes to the non-managed/VBA add-in.
VBA add-ins don't have their own namespace by default, but can have one. If you create a custom namespace, then multiple VBA add-ins can share the same tab on the ribbon, for example.
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"
xmlns:nsMySpace="SomeName">
Then to create a new tab that other add-ins can share:
<tab idQ="nsMySpace:MySpace_Tab" label="MyTabLabel">
In addition to Steve's answer we've discovered that VBA add-ins have a default namespace even when none is specified in their customUI.
You can extract the namespace by adding a control from the ribbon to the Quick Access and then exporting the UI Customizations. The resulting file should show:
<mso:cmd app="PowerPoint" dt="1" />
<mso:customUI xmlns:x1="C:\Users\USERNAME\AppData\Roaming\Microsoft\AddIns\Addin.ppam">
So the default namespace seems to be the complete Path to the add-in.
From a high perspective two add-ins can share a ribbon tab for controls because they are loaded into a single PowerPoint instance. When you develop a macro enabled file with a custom UI - only this file can be opened at the same time. But two add-ins can be run for the file/template. That's why idQ is intended to use by add-ins.
You can read more about the Fluent UI (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)