Print Dialog Box pre-select choices

briannakmg

New Member
Joined
Jan 26, 2006
Messages
42
I am looking to have the print dialog box pop up for the users of my spreadsheet and I need the "selection" radio button under "Print What" to be selected instead of "Active Sheet(s)". I've already got everything selected I just don't think the users will remember to choose "selection" when they print.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,253
Office Version
  1. 2016
Platform
  1. Windows
This should work :

Place this in a standard module in your project :

Code:
Public Declare Function SetTimer _
Lib "user32" _
    (ByVal hwnd As Long, _
    ByVal nIDEvent As Long, _
    ByVal uElapse As Long, _
    ByVal lpTimerFunc As Long) As Long
 
Public Declare Function KillTimer _
Lib "user32" _
    (ByVal hwnd As Long, _
    ByVal nIDEvent As Long) As Long
    
Public lTimerID As Long
 
Public Sub TimerProc()
 
    KillTimer 0, lTimerID
    SendKeys "%n", True
 
End Sub


Place this in the workbook module :

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
 
    lTimerID = SetTimer(0, 0, 1, AddressOf TimerProc)
 
End Sub

Regards.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
37,103
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
You can also use:
Code:
application.Dialogs(xlDialogPrint).Show ,,,,,,,,,,,1
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,253
Office Version
  1. 2016
Platform
  1. Windows
You can also use:
Code:
application.Dialogs(xlDialogPrint).Show ,,,,,,,,,,,1

Rory,

The arguments of dialogs are not documented on help files . How/where did you find out about them ?

Thanks ahead.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
37,103
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS

ADVERTISEMENT

Jaafar,
They are basically the same arguments you would use with the old XLM macro functions, so if you get hold of the Macrofun.hlp help file, you can usually figure out the arguments for most dialogs - they're in the same order, thankfully!
Edit: you can hopefully still get the file here.
 
Last edited:

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,253
Office Version
  1. 2016
Platform
  1. Windows
Jaafar,
They are basically the same arguments you would use with the old XLM macro functions, so if you get hold of the Macrofun.hlp help file, you can usually figure out the arguments for most dialogs - they're in the same order, thankfully!
Edit: you can hopefully still get the file here.

:) Installed the help files - great info . Will be exploring those XLM macros.


PRINT(range_num, from, to, copies, draft, preview, print_what, color, feed, quality, y_resolution, selection)

Many thanks.
 

briannakmg

New Member
Joined
Jan 26, 2006
Messages
42
I knew it was something simple, just couldn't find anything in the help menus on how many commas I would need!

Thanks so much,
Brianna
 

Forum statistics

Threads
1,136,331
Messages
5,675,156
Members
419,552
Latest member
jsanjur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top