Avatar of Jamie Garroch (MVP)
Jamie Garroch (MVP)
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Using VBA to repurpose built-in Microsoft PowerPoint controls for Paste, paste With Source Formatting and paste Using Destination Theme

The Office fluent UI supports repurposing of button, toggleButton and checkBox controls.

I want to repuropse the following three paste commands in PowerPoint which are all defined as button controls in the Microsoft documentation:

Paste, PasteSourceFormatting, PasteDestinationTheme

Here is the resulting customUI:

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
		<!-- Repurpose built in button, toggleButton or checkBox controls -->
		<command idMso="Paste" onAction="OnAction"/>
		<command idMso="PasteSourceFormatting" onAction="OnAction"/>
		<command idMso="PasteDestinationTheme" onAction="OnAction"/>

Open in new window

And here is a simple VBA callback procedure to determine which button was pressed:

Sub OnAction(control As IRibbonControl, ByRef cancelDefault)
    Debug.Print control.Id
    cancelDefault = False
End Sub

Open in new window

If I now copy a slide in PowerPoint and paste it using Ctrl+V I see the debug output for "Paste".

If I then use the Paste drop down menu in the Home tab to use either of the other two commands I don't see any debug output nor error so it seems these controls are not being repurposed.

This digitally signed project file includes the above example:


Why isn't this working?
Microsoft OfficeVBAMicrosoft PowerPoint

Avatar of undefined
Last Comment
Jamie Garroch (MVP)

8/22/2022 - Mon