none
Error calling VBA callbacks using module.sub naming convention from custom menu RRS feed

  • Question

  • Access 2010 using USysRibbons method to display menu tab

    Error: Microsoft Access cannot run the macro or callback function 'module_name.sub_name'.

    XML:

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="CallbackOnLoad">
      <ribbon startFromScratch="false">
        <tabs>
          <tab id="MyTab" label="Button Demo">
            <group id="MyGroup" label="Button Demo">
     
                 <button id="MyBtn1" getSize="CallbackGetSize" label="Button 1" imageMso="BevelShapeGallery"
                   getKeytip="CallbackGetKeytip" onAction="basButton.MyButtonCallbackOnAction"
                   getShowLabel="MyButtonCallbackShowLabel"
                   getShowImage="MyButtonCallbackShowImage"
                   getScreentip="CallbackAllgGetItemScreentip" getSupertip="CallbackAllgGetItemSupertip"/>
                 <button id="MyBtn2" getSize="CallbackGetSize" getLabel="CallbackGetLabel" imageMso="BevelShapeGallery"
                   getKeytip="CallbackGetKeytip"
                   getShowImage="MyButtonCallbackShowImage"
                   onAction="MyButtonCallbackOnAction"/>
            </group>
          </tab>  
        </tabs>
      </ribbon>

    The callback MyButtonCallbackOnAction is located in module basButton

    This behaviour is inconsistent with Word 2010 where you can use 'module_name.sub_name' convention. The above error message does not indicate that this naming convention is not supported.

    Hope this helps someone.

    Saturday, October 14, 2017 4:45 AM

All replies

  • Hi,

    If you're calling a public function, try adding an equal sign to the call. For example:

    onAction="=basButton.MyButtonCallbackOnAction"

    Hope it helps...

    Saturday, October 14, 2017 3:02 PM
  • Hello,

    I could reproduce the issue. 

    We could use onAction="MyButtonCallbackOnAction" or onAction="=test()" in the XML. Add a module reference would not work. 

    Sub MyButtonCallbackOnAction(control As IRibbonControl)
    MsgBox ("Hello")
    End Sub
    
    Function test()
    MsgBox ("test")
    End Function

    According to Customizing the Office Fluent User Interface in Access 2007, we could also use onAction="MacroObjectName.MacroName" if using a macro object.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, October 16, 2017 7:37 AM
    Moderator