Abo Abd_Allah
New member
- Local time
- Today, 13:07
- Joined
- Sep 23, 2016
- Messages
- 16
Hi All
I use this code to display a shortcut menu of reports when I click the right mouse button
But I want to pass the name of the current report to this routine so that I can export the report to Excel
I use this code to display a shortcut menu of reports when I click the right mouse button
But I want to pass the name of the current report to this routine so that I can export the report to Excel
Code:
Dim cmbRightClick As Office.CommandBar
Dim cmbControl As Office.CommandBarControl
On Error Resume Next
' Create the shortcut menu.
Set cmbRightClick = Application.CommandBars.Add("MyRepRightClkMenu", msoBarPopup, False, True)
With cmbRightClick
set cmbControl=.controls.add
With cmbControl
.Caption = "Export to Excel"
.FaceId = 11723
.OnAction = "=ExportExcelSb(me.name)"
End with
End with
'this sub for Export
'============
Public Sub ExportExcelSb(ByVal repname As String)
Dim savPas As String
savPas = calFilDilog(2, "Expor To Excel")
DoCmd.OutputTo acOutputReport, repname, "Excel97-Excel2003Workbook(*.xls)", savPas, True, "", , acExportQualityPrint
End Sub