Solved

Access 2010 - shortcut right click menu for reports

Posted on 2013-11-10
5
2,816 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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

743 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

12 Experts available now in Live!

Get 1:1 Help Now