问题
I have recently switched to Mac from my Windows work laptop where I had some nice features installed via PowerPoint add-ins that I would like to replicate.
I have all my macros working, and I am now trying to turn them into a working add-in that I can load on my machine.
Now, before we get to the tricky part of signing the add-in and bla bla bla.. I am starting really simple (pptm file with custom toolbar). I have followed ron de bruin's amazing guide. However, when I launch my presentation on Mac (on Windows they work), the buttons don't trigger the macro (no matter what macro).
Here is the customUI.xml files content
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab id="MyCustomTab" label="My Tab" insertAfterMso="TabHome">
<group id="customGroup1" label="Group 1">
<button id="customButton1" label="Caption 1" size="normal" onAction="Macro1" imageMso="Cut" />
<button id="customButton2" label="Caption 2" size="normal" onAction="Macro2" imageMso="Bold" />
<button id="customButton3" label="Caption 3" size="normal" onAction="Macro3" imageMso="Italic" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
And here is the content of my macro's module in VBA:
Option Explicit
'Callback for customButton1 onAction
Sub Macro1(control As IRibbonControl)
MsgBox "This is macro 1"
End Sub
'Callback for customButton2 onAction
Sub Macro2(control As IRibbonControl)
MsgBox "This is macro 2"
End Sub
'Callback for customButton3 onAction
Sub Macro3(control As IRibbonControl)
MsgBox "This is macro 3"
End Sub
Any idea what I am doing wrong?
回答1:
I can confirm that the connection between XML and VBA callbacks in PowerPoint for Mac is broken. Using your sample XML and VBA, I created identical ribbon mods in PowerPoint, Word and Excel macro-enabled files. All three worked as expected in Windows. Only Word and Excel worked as expected in Office 2019 for Mac.
I've reported this bug to Microsoft using the smailey-face icon in the upper-right of the program window.
回答2:
I have made it possible to (temporarily) solve the issue by setting the following preferences in "Security and Privacy":
* Macro Security > Enable All
* Trust access to the VBA project object model
* Allow actions to run programs without notification
Hoper this helps
来源:https://stackoverflow.com/questions/57733141/developing-a-custom-ribbon-add-in-for-powerpoint-office-365-mac