Solved

Access 2010 - shortcut right click menu for reports

Posted on 2013-11-10
5
2,849 Views
Last Modified: 2013-11-11
I am using the lovely code snippet provied by Microsoft to set up a right click report menu.  All good.  The client now wants to add the option to export to Excel.  Does anyone know the correct bit of code such as .Controls.Add(msoControlButton, 2521) for this option?
Sub CreateReportShortcutMenu()
    'for runtime versions, report preview right click option to print is not available,
    'so we need to create a shortcut menu bar here and then assign it in each report property sheet "Shortcut menu bar"
    'just need to create once - can run from immediate window by 'call CreateReportShortcutMenu'
    'can't seem to delete so if you need to change, you will need to create new one with different name
    'to delete - try commandbars.item("xxx").delete
    
    Dim cmbRightClick As Office.CommandBar
    Dim cmbControl As Office.CommandBarControl

    Set cmbRightClick = CommandBars.Add("cmdReportsRightClick2", _
                                        msoBarPopup, False, False)
    With cmbRightClick
        
        ' Add the Print command.
        Set cmbControl = .Controls.Add(msoControlButton, 2521)
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Quick Print"
        
        ' Add the Print command.
        Set cmbControl = .Controls.Add(msoControlButton, 15948)
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Print ..."
        
        ' Add the Page Setup... command.
        Set cmbControl = .Controls.Add(msoControlButton, 247)
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Page Setup ..."
        
        ' Add the Mail Recipient (as Attachment)... command.
        Set cmbControl = .Controls.Add(msoControlButton, 2188)
        ' Start a new group.
        cmbControl.BeginGroup = True
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Email Report as an Attachment"
        
        ' Add the PDF or XPS command.
        Set cmbControl = .Controls.Add(msoControlButton, 12499)
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Save as PDF/XPS"
        
        ' Add the Close command.
        Set cmbControl = .Controls.Add(msoControlButton, 923)
        ' Start a new group.
        cmbControl.BeginGroup = True
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Close Report"
    End With
    
    Set cmbControl = Nothing
    Set cmbRightClick = Nothing
End Sub

Open in new window

0
Comment
Question by:MonkeyPie
  • 3
  • 2
5 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 39638412
Get this, from the Microsoft Download Center:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=6627

It has all of the mso ID's, organized by product.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39638421
If you look in the spreadsheet for Access, I think the one you are looking for is just "ExportExcel".  You would add them to a ribbon using the Name, but for your command bar coding, the numbers listed on the right might be what you need (not sure), so try 2862.
0
 

Author Comment

by:MonkeyPie
ID: 39640661
Thank you mbizup,  but I need a bit more help here.  I have done as you suggest and downloaded the Office 2010 Help Files: Office Fluent User Interface Control Identifiers.  Microsoft's 'Instructions for Use' are less than helpful ...
'After you have installed this download, view the files using Excel 2007 or Excel 2010 as you normally would'  !!

So, I opened EXCEL and went to HELP.  Searched for various things 'Interface Control Identifiers' etc.  Got no-where.  Tried the same thing in Access.

What exactly do they mean when they say... view the files using Excel 2007 or Excel 2010 as you normally would?

Also, I'm not sure what you mean by..
If you look in the spreadsheet for Access, I think the one you are looking for is just "ExportExcel".  You would add them to a ribbon using the Name, but for your command bar coding, the numbers listed on the right might be what you need (not sure), so try 2862.

What is the 'spreadsheet for Access'?  What numbers listed on the right?

Thank you for your help.
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39640677
That installation file basically unzips a whole bunch of excel files into a default folder or a folder of your choosing.  The filenames indicate which office product each file applies to, and you can open them to see the control names, ids and other info.
0
 

Author Closing Comment

by:MonkeyPie
ID: 39640688
Ah!  Thank you.  I see in the AccessControls.xlxs the one ExportExcel is number 11723.  I'll give that a go.  Thank especially for quick response.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now