PDA

View Full Version : [SOLVED] "The macro cannot be found" when clicking on the ribbon



nickgearls
04-20-2022, 03:52 AM
In Powerpoint (Office365, v18.2110), I created a ribbon button like this:

<mso:button id="updateProperties" visible="true" label="updateProperties" imageMso="RecurrenceEdit" onAction="updatePropertiesCallback"/>


In my VBA project (where all macros are working), I added the callback:

Sub updatePropertiesCallback(control As IRibbonControl)
MsgBox "test"
End Sub


When I click the button, I receive the following message:
"The macro cannot be found or has been disabled because of your security settings"

Any idea?
Thanks a lot

Paul_Hossler
04-20-2022, 06:10 AM
How did you add the XML?

It'd be easier if you would attach a small presentation with the macro, etc.

This is my XML. The attachment seems to work, so maybe it's one of your settings??



<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="customTab" label="Custom Tab">
<group id="customGroup" label="Custom Group">
<button id="updateProperties" label="updateProperties" imageMso="RecurrenceEdit" size="large" onAction="updatePropertiesCallback" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>

nickgearls
04-20-2022, 06:50 AM
Here is an example of PPTM and my custom ribbon

Aflatoon
04-21-2022, 01:15 AM
The onAction in that template is just set to "Callback"

Paul_Hossler
04-21-2022, 07:19 AM
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="customTab" label="Custom Tab">
<group id="customGroup" label="Custom Group">
<button id="customButton" label="Custom Button" imageMso="HappyFace" size="large" onAction="updatePropertiesCallback" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>



BTW, the onAction in the XML in your post #1 was correct, but wrong in the PPTM


<mso:button id="updateProperties" visible="true" label="updateProperties" imageMso="RecurrenceEdit" onAction="updatePropertiesCallback"/>

nickgearls
04-22-2022, 08:54 AM
Forget about the customUI in the PPTM, it was a test.
I uploaded one without this customUI (but the same VBA). Or take any PPTM, add the VBA code, import the customUI from ribbon.zip and you should (I imagine) get the same error message as me.

Aflatoon
04-22-2022, 09:54 AM
The customUI needs to be in the template to work as is. An application wide macro button needs a specific filename in the onAction property

nickgearls
04-22-2022, 10:39 AM
Probably stupid questions:
1. How do I put a customUI needs to be in the template?
2. Can I use an absolute filename to a file containing macros I want to use in all presentations?

Paul_Hossler
04-22-2022, 04:15 PM
1. One of us is very confused

2. Based on the zipped customizations file, it looks like you're adding a macro named updatePropertiesCallback to the QAT (not the Ribbon):


<mso:cmd app="PowerPoint" dt="1" /><mso:customUI xmlns:macro="http://schemas.microsoft.com/office/2009/07/customui/macro" xmlns:mso="http://schemas.microsoft.com/office/2009/07/customui">
<mso:ribbon>
<mso:qat>
<mso:sharedControls>
<mso:control idQ="mso:FileNewDefault" visible="false" insertBeforeQ="mso:AutoSaveSwitch"/>
<mso:control idQ="mso:FileOpenUsingBackstage" visible="false" insertBeforeQ="mso:AutoSaveSwitch"/>
<mso:control idQ="mso:FileSave" visible="false" insertBeforeQ="mso:AutoSaveSwitch"/>
<mso:control idQ="mso:FileSendAsAttachment" visible="false" insertBeforeQ="mso:AutoSaveSwitch"/>
<mso:control idQ="mso:FilePrintQuick" visible="false" insertBeforeQ="mso:AutoSaveSwitch"/>
<mso:control idQ="mso:PrintPreviewAndPrint" visible="false" insertBeforeQ="mso:AutoSaveSwitch"/>
<mso:control idQ="mso:Spelling" visible="false" insertBeforeQ="mso:AutoSaveSwitch"/>
<mso:control idQ="mso:SlideShowFromBeginning" visible="false" insertBeforeQ="mso:AutoSaveSwitch"/>
<mso:control idQ="mso:PointerModeOptions" visible="false" insertBeforeQ="mso:AutoSaveSwitch"/>
<mso:control idQ="mso:AutoSaveSwitch" visible="false"/>
<mso:control idQ="mso:Undo" visible="false"/>
<mso:control idQ="mso:RedoOrRepeat" visible="false"/>
<mso:control idQ="mso:FormatPainter" visible="true"/>
<mso:control idQ="mso:FontColorPicker" visible="true"/>
<mso:control idQ="mso:BulletsGallery" visible="true"/>
<mso:control idQ="mso:LanguageCommands" visible="true"/>
<mso:control idQ="mso:ReviewNewComment" visible="true"/>
<mso:control idQ="mso:SymbolInsert" visible="true"/>
<mso:control idQ="mso:AnimationAddGallery" visible="true"/>
<mso:control idQ="mso:ViewSlideMasterView" visible="true"/>
<mso:control idQ="mso:MasterViewClose" visible="true"/>
<mso:button id="updateProperties" visible="true" label="updateProperties" imageMso="RecurrenceEdit" onAction="updatePropertiesCallback"/>
</mso:sharedControls>
</mso:qat>
</mso:ribbon>
</mso:customUI>


You can call it a callback, but it really isn't; it's just the name of the macro, and AFAIK doesn't take parameters



3. So defining the macro's call like this is for ribbon controls (not customizations) and is the reason that the QAT button cannot find a macro in that PPTM



Option Explicit

Sub updatePropertiesCallback(control As IRibbonControl)
MsgBox "test"
End Sub



4. Defined like this, the QAT icon does find the macro, and you could give it a more meaningful name like "updateProperties"



Option Explicit

Sub updatePropertiesCallback()
MsgBox "test"
End Sub


29674


5.


2. Can I use an absolute filename to a file containing macros I want to use in all presentations?

Make it an add in (PPAM file) and use 'ActivePresentation'. The macros are all in the add in

nickgearls
04-23-2022, 02:24 AM
I implemented in a PPAM and it works now.
Thanks a lot