Disabling buttons in the default ribbon in PowerPoint - vba

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)

Related

Implementing IRibbonExtensibility_GetCustomUI from VBA

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)

Is getLabel safe to use (VBA, PowerPoint)?

I would like to use a getLabel callback from some custom XML in a PowerPoint ppam in order to localise text in the Ribbon. My concern is that doing this could cause error messages to appear from time to time when starting PowerPoint ("PowerPoint can't start this feature because you currently have a Visual Basic for Applications project in break mode.") as users have experienced with an add-in that uses a getEnabled callback. I have already asked a question about other options for localising the ribbon.
Do you use getLabel in a PowerPoint ppam add-in? If so, do you sometimes see this error message when PowerPoint is started? Additionally, do you use getEnabled, and does this ever cause this error message to be displayed when PowerPoint starts up?
Answers either way would be great.
This is what I am testing:
Custom UI XML fragment:
<button id="app1ShowAMsg"
imageMso="TableInsert"
size="normal"
onAction="app1ShowAMessage"
label="app1GetLabel"/>
VBA code:
Public Sub app1GetLabel(control As IRibbonControl, ByRef returnedVal)
Select Case control.Id
Case "app1ShowAMsg"
returnedVal = "My added label"
End Select
End Sub
Public Sub app1ShowAMessage()
MsgBox "You clicked a button."
End Sub
Yes, it is. I don't see anything strange in using the getLabel callback along with others. Moreover, that is the recommended way of implementing any dynamism on the Fluent UI - for changing the caption string and etc. at runtime. The Fluent 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)
Also you may find the following articles helpful:
Chapter 11: Creating Dynamic Ribbon Customizations (1 of 2)
Chapter 11: Creating Dynamic Ribbon Customizations (2 of 2)

PowerPoint 2010 - VBA - Use Ribbon Button Inside of a Userform

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)

How to make changes in Ribbon elements of a single excel instance, using application-level add-in?

I'm using VSTO with VB.NET for Excel 2013. I'm developing an application-level add-in, but I can't make two different workbooks store different "ribbon state". For example, when I want to enable a button, I use the following code:
Globals.Ribbons.Ribbon1.myButton.Enable = False
This makes the element "myButton" to be disabled on each opened workbook, but I want to make it disabled only for one workbook.
The way I'm doing now is to handle the event WorkbookActivate, to change the ribbon state. The problem is: this way, the user sees an invalid state at other workbooks that are not on the top.
There is some better workaround? There isn't a way to manage the ribbon instances (and not only the global element as I am doing)?
Thanks
There is some better workaround? There isn't a way to manage the ribbon instances (and not only the global element as I am doing)?
You need to use callbacks instead. Try to use the getEnabled callback instead.
Moreover, when required you can use the IRibbonUI interface methods to force Office applications to update the UI controls. The Invalidate method invalidates the cached values for all of the controls of the Ribbon user interface. See Overview of the IRibbonUI Object .
You can read more about the Ribbon UI (aka Fluent 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)

Outlook create a button like 'Private'

I want to create a button like the 'Private' button when creating a new appointment/meeting. So that the button freeze in the mouse hover style when it gets clicked.
I create the button in the VBA project like this:
Set objCBC = objCB.Controls.Add(Type:= --WHICHTYPE--, _
Temporary:=True)
So does anybody know which type of button should be applied here??
Command bars were deprecated. You need to use the Fluent UI (aka Ribbon UI) instead. Unfortunately Outlook doesn't allows to customize the Fluent UI with VBA, you need to develop an add-in instead. You can read more about the new 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)
See the toggleButton control in the list of available controls.