Consulting

Results 1 to 10 of 10

Thread: "The macro cannot be found" when clicking on the ribbon

  1. #1

    "The macro cannot be found" when clicking on the ribbon

    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

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Posts
    8,337
    Location
    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>
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Here is an example of PPTM and my custom ribbon
    Attached Files Attached Files

  4. #4
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,615
    Location
    The onAction in that template is just set to "Callback"
    Be as you wish to seem

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Posts
    8,337
    Location
    <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"/>
    Attached Files Attached Files
    Last edited by Paul_Hossler; 04-21-2022 at 08:06 AM.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  6. #6
    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.
    Attached Files Attached Files

  7. #7
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,615
    Location
    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
    Be as you wish to seem

  8. #8
    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?

  9. #9
    VBAX Sage
    Joined
    Apr 2007
    Posts
    8,337
    Location
    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
    Capture.JPG


    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
    Last edited by Paul_Hossler; 04-22-2022 at 04:47 PM.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  10. #10
    I implemented in a PPAM and it works now.
    Thanks a lot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •