I am developing a PowerPoint add-in and would like to temporarily disable some of the Ribbon controls while the add-in application is running.
I have developed a solution that works as expected when the Add-In is enabled, but this is not really adequate, because it disables some commonly used controls, like SlideMaster, SlideSorter, etc.
I am using PowerPoint 2010.
Here is a sample XML which is well-formed:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false">
<tabs>
<tab idMso="TabView">
<group idMso="GroupMasterViews" getVisible="GetVisible"/>
</tab>
</tabs>
</ribbon>
</customUI>
Here is a sample callback, taken from this SO answer:
Sub GetVisible(control As IRibbonControl, ByRef returnedVal As Boolean)
If TrapFlag Then
returnedVal = False ' control is hidden
Else:
returnedVal = True ' control is not hidden
End If
End Sub
When I navigate to the View
ribbon, an alert informs me that:
The macro cannot be found or has been disabled because of your security settings.
Presumably this is referring to the GetVisible
macro? My macro settings are:
- Enable all macros (not recommended)
- Trust access to the VBA project object model
I have been struggling with what I have found so far but so far unable to implement suggestions. Most answers are specific to Excel. I have not really found anything specific to PowerPoint, but figured it should not be terribly difficult to port code from one application to another, as I have done this for many other things in VBA.
I have also tried this method, but the SetCustomUI
is not available in PowerPoint at the Application
or Presentation
level, perhaps it is unique or only applicable to Visual Studio?