Opening the print Dialog in VBA (1 Viewer)

smig

Registered User.
Local time
Today, 07:43
Joined
Nov 25, 2009
Messages
2,209
I'm creating my oun ribbon
Right now the Print and Page Setup Dialogs are used "As Is"

Code:
<group id="grpReports2" label=" ">
	<button idMso="PrintDialogAccess"
		size="large"
		label="Print"/>
	<button idMso="PageSetupDialog"
		size="large"
		label="Page Setup"/>

I want to open these dialogs using VBA so I can have some more action before/after printing.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:43
Joined
Oct 29, 2018
Messages
21,467
Hi. In your Ribbon Callback, try the following command.

DoCmd.RunCommand acCmdPrint
 

smig

Registered User.
Local time
Today, 07:43
Joined
Nov 25, 2009
Messages
2,209
Hi. In your Ribbon Callback, try the following command.

DoCmd.RunCommand acCmdPrint
Thanks,

And what about the Page Setup Dialog ?
 

isladogs

MVP / VIP
Local time
Today, 05:43
Joined
Jan 14, 2017
Messages
18,216
I recommend you look at the various tutorials at the Access Ribbon Creator site run by Gunter Avenius: https://www.accessribbon.de/

You can also download a trial version of his ribbon creator utility or purchase the full version. It will probably save you a lot of time
 

smig

Registered User.
Local time
Today, 07:43
Joined
Nov 25, 2009
Messages
2,209
I recommend you look at the various tutorials at the Access Ribbon Creator site run by Gunter Avenius: https://www.accessribbon.de/

You can also download a trial version of his ribbon creator utility or purchase the full version. It will probably save you a lot of time
Thanks, but I have a very nice working ribbon :)

I only need some help for the correct commands to run the Print dialog and Page Setup Dialog from VBA.
 

isladogs

MVP / VIP
Local time
Today, 05:43
Joined
Jan 14, 2017
Messages
18,216
That's why I suggested you look at the tutorials on that site
 

isladogs

MVP / VIP
Local time
Today, 05:43
Joined
Jan 14, 2017
Messages
18,216
Nor mine - it has an English version! :D
Translate option at top right
 

smig

Registered User.
Local time
Today, 07:43
Joined
Nov 25, 2009
Messages
2,209
in the FAQ he say to use:
Application.CommandBars.ExecuteMso ("idMSO")

is it better then using the
DoCmd.RunCommand
?
 

June7

AWF VIP
Local time
Yesterday, 20:43
Joined
Mar 9, 2014
Messages
5,470
It is my understanding it is better to use RunCommand whenever possible. The only time I have seen need to resort to the old CommandBars is for RefreshAll.

CommandBars.ExecuteMso "DataRefreshAll"

So the ribbon has nothing to do with what you want to accomplish?
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 05:43
Joined
Jan 14, 2017
Messages
18,216
I'm not the best person to answer your specific question.
I have several apps where I remove the application window, ribbon, nav pane etc. However when a report is opened the print preview ribbon is shown. When the report is closed the ribbon is removed once again

You can see an example of this in action at: https://www.access-programmers.co.uk/forums/showthread.php?t=293584.
The latest version is in post #10
Click the Open New Form button then click View Report

As this is so easy, I've never felt the need to do a custom print ribbon

I also have a number of apps where I remove the default ribbons and add my own custom ribbon. For example:



As I only do it once a year I tend to use the free version of the Ribbon Creator tool.
 

Attachments

  • RibbonExample.PNG
    RibbonExample.PNG
    21.3 KB · Views: 2,019

smig

Registered User.
Local time
Today, 07:43
Joined
Nov 25, 2009
Messages
2,209
In my app I use my oun ribbons, and they work perfectly.
I hide them and show them when I need.

The only commands I left original are the Print Dialog and the Page Setup Dialog.

I changed now the Print Dialog as I needed to run some code to set the paper as printed (Set invoices and receipts as printed) :)
 

Users who are viewing this thread

Top Bottom