Creating Ribbon Menu in VBA

Ribbon Menu’s are controlled by the table USysRibbon and the function MyButtonCallbackOnAction

Download my sample application , in the Ribbon table I have included the Ribbon for the application a reporting ribbon and sample of other ribbons I have used in the past. The ribbon menus are written in XML , set your application to use this as the application default ribbon and set the ribbon on your reports to use the ReportRibbon.


Reports Ribbons
Ribbon Menu
Ribbon Menu Callback VBA
Sub MyButtonCallbackOnAction(control As IRibbonControl)
On Error GoTo Error_Handler
    ' Callback Button Click
    Dim tmpCurrForm
Select Case control.ID
    
    Case "quit"
        DoCmd.Quit
    Case "close1"
        DoCmd.Close
    Case "cmdDesign"
        DoCmd.OpenForm "frmDesignStart"
    Case "cmdRibon"
        DoCmd.OpenForm "frmRibbon"
    Case "cmdCodeLib"
        DoCmd.OpenForm "frmCodeLibrary"
    Case "cmdSize"
        DoCmd.OpenForm "frmSizing"
    Case "cmdReports"
        DoCmd.OpenForm "frmReports"
    Case "cmdExcelExport"
        DoCmd.OpenForm "frmExcel"
    Case "cmdOverview"
        DoCmd.OpenForm "frmETL"
    Case "ProcessImport"
        DoCmd.OpenForm "frmImports"
    Case "ImportDefintions"
        DoCmd.OpenForm "frmImportGeneric"
    Case "Transform"
        DoCmd.OpenForm "frmCustomSQL"
    Case "cmdAttach"
        RunCommand acCmdLinkedTableManager
    Case "cmdPref"
        DoCmd.OpenTable "tblPreferences"
    Case "Expe"
        DoCmd.OpenForm "frmExcelExport"
    Case "cmdReset"
        DoCmd.OpenForm "frmReset"
    Case Else
        MsgBox control.ID & "  Not Available in this release"
End Select
    
Exit Sub

Error_Handler:

If Err.Number = 2501 Then
    Exit Sub
Else
    MsgBox "Error " & Err.Number & " - " & Err.Description
End If
End Sub

Link to MS Article

Also checkout https://www.accessribbon.de/en/?Downloads for more detailed samples and functions.

, ,

Leave a Reply

Your email address will not be published. Required fields are marked *