none
How to call methods from a custom ribbon in Access 2016? RRS feed

  • Question

  • I'm trying to make my custom ribbon call methods following an Access 2007 tutorial, but some things seem to have changed in Access 2016. The sample code is:

    Option Compare Database
    Option Explicit
    
    Public globalRibbon As IRibbonUI
    
    'Get a global reference to the ribbon object when the ribbon loads
    Public Sub onRibbonLoad(ByVal ribbon As IRibbonUI)
        Set globalRibbon = ribbon
    End Sub
    
    'Open the form that is specified in the ribbon control's tag property
    Public Sub ribOpenForm(control As IRibbonControl)
        DoCmd.OpenForm (control.Tag)
    End Sub

    And the XML call would be:

    <button id="MainMenu" label="Main menu" size="large" imageMso="NewOfficeDocument"

    tag ="frmMainMenu" onAction="ribOpenForm"/>

    Neither IRibbonUI nor IRibbonControl seem to exist anymore, so how can I call VBA code now? Anyone know of an updated sample/tutorial?

    TIA!

    Dennis


    • Edited by sgude1 Saturday, August 13, 2016 7:19 PM typo
    Saturday, August 13, 2016 6:30 PM

Answers

  • I found the solution. It's not enough to reference the Microsoft Access 16.0 Object Library, you also need the Microsoft Office 16.0 Object Library.

    Re

    D

    • Marked as answer by sgude1 Saturday, August 13, 2016 9:18 PM
    Saturday, August 13, 2016 9:18 PM

All replies

  • Are you getting any errors? What happens if you change the code to?

    DoCmd.OpenForm control.Tag

    (without the brackets)

    Saturday, August 13, 2016 7:15 PM
  • Yes, it won't compile. "User-defined type not specified" for both IRibbonUI and IRibbonControl even though I have a reference to Microsoft Access 16.0 Object Library where it should be (at least it used to be there in previous versions)

    Re

    Dennis


    • Edited by sgude1 Saturday, August 13, 2016 7:20 PM
    Saturday, August 13, 2016 7:18 PM
  • I found the solution. It's not enough to reference the Microsoft Access 16.0 Object Library, you also need the Microsoft Office 16.0 Object Library.

    Re

    D

    • Marked as answer by sgude1 Saturday, August 13, 2016 9:18 PM
    Saturday, August 13, 2016 9:18 PM
  • Hi. Congratulations!  Glad to hear you got it sorted out. Good luck with your project.
    Saturday, August 13, 2016 10:21 PM