Private Sub Report_Load()
CreateReportShortcutMenu 'Loads shortcut menu
End Sub
Private Sub CreateReportShortcutMenu()
'==================================================================================================
'//In the Report_Load Event enter CreateReportShortcutMenu then in the reports Property/Shortcut
' Menu Bar enter the MenuName "vbaShortCutMenu"
'
' You must Reference to Microsoft Office xx.0 Object Library
' Office 2003 - use 11.0
' Office 2007 - use 12.0
' Office 2010 - use 14.0
' Office 2013 - use 15.0
' This Reference IS NOT the same as Microsoft Office 14.0 Access database engine Object Library
'==================================================================================================
Dim MenuName As String
Dim CB As CommandBar
Dim CBB As CommandBarButton
MenuName = "vbaShortCutMenu"
On Error Resume Next
Application.CommandBars(MenuName).Delete
On Error GoTo 0
'Create the menu
Set CB = Application.CommandBars.Add(MenuName, msoBarPopup, False, False)
'The following code creates the options for the menu
Set CBB = CB.Controls.Add(msoControlButton, 15948, , , True)
CBB.Caption = "Print..."
Set CBB = CB.Controls.Add(msoControlButton, 7, , , True)
CBB.Caption = "Zoom: 100%"
Set CBB = CB.Controls.Add(msoControlButton, 12499, , , True)
'Starts a new group.
CBB.BeginGroup = True
'Change the caption displayed for the control.
CBB.Caption = "Save as PDF"
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Send By E-mail..."
CBB.Tag = "Send E-mail..."
CBB.OnAction = "=EmailAsPDF()" 'Calls a module with Function EmailAsPDF()
'Adds the Close command.
Set CBB = CB.Controls.Add(msoControlButton, 923, , , True)
'Starts a new group.
CBB.BeginGroup = True
'Change the caption displayed for the control.
CBB.Caption = "Close Report"
Set CB = Nothing
Set CBB = Nothing
End Sub