Solved

Access 2010 - shortcut right click menu for reports

Posted on 2013-11-10
5
2,910 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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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 …

821 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