XLDialogPrint - PrintWhat- Selection Option

G

Guest

Is there any way that I can make the windows printer dialogue box appear and
select the option "Selection" automatically in the "Print_What" area? I tried
the following but it doesn't select "Selection" and when I try to print it
keeps coming back.

Application.Dialogs(xlDialogPrint).Show ,,,,,,selection
 
G

Guest

Sub AABB()
res = Application.Dialogs( _
xlDialogPrint).Show(, , , , , , , , , , , 1)
End Sub

worked for me.
 
Joined
Jul 30, 2014
Messages
2
Reaction score
0
Arg1: Range_Num: defines which pages to print:
1 = all pages in the workbook
2 = a specified range defined by the From and To values
Arg2: From: the first page to print (if Range_Num = 2)
Arg3: To: the last page to print (if Range_Num = 2)
Arg4: Copies: the number of copies to print (default=1)
Arg5: Draft: if specified, overrides the Draft quality setting of the Sheet tab of the xlDialogPrinterSetup dialog (the “Page Setup” dialog).
Arg6: Preview:
For the Excel4 PRINT macro:
True = the print-preview window is displayed
False = the print-preview window is not displayed
For VBA in Excel5 and later versions, has no effect. Use the xlDialogPrintPreview dialog instead.
Arg7: Print_What: print sheet (cell values) and/or notes (comments).
For the Excel4 PRINT macro, if specified, overrides the Notes setting of the PAGE.SETUP macro (the “Page Setup” dialog):
1 = Sheet (cell values) only
2 = Notes only
3 = Sheet and then notes
For VBA in Excel5 and later versions, if specified, overrides some Comments settings on the Sheet tab of the xlDialogPrinterSetup dialog:
1 = Overrides the “Page Setup” dialog’s Comments setting of “At end of sheet” to suppress printing of comments.
2 = Overrides the “Page Setup” dialog’s Comments setting of “(None)” to print comments (at the end of the sheet).
3 = (same as 1)
Note: has no effect on the Comments setting of “As displayed on sheet”.
Arg8: Color: if specified, overrides the Print Using Color setting in Excel for Mac.
Arg9: Feed: if specified, overrides the paper Feed Type setting in Excel for Mac.
1 = Continuous, for paper cassette (default)
2 = Cut sheet or manual feed
Arg10: Quality: if specified, overrides the Print quality setting on the Page tab of the xlDialogPrinterSetup dialog
Arg11: Y_Resolution: if specified and the selected printer has a vertical resolution that is different from the horizontal resolution (e.g. a dot matrix printer) then this setting overrides the Print quality setting on the Page tab of the xlDialogPrinterSetup dialog, for the vertical resolution.
Arg12: Selection: the (default) setting of the “Print what” section of the dialog:
1 = Selection (i.e. the selected cells and objects)
2 = Active sheet(s)
3 = Entire workbook
4 = List (the selected Excel List range)
Arg13: Printer_Text: The printer name. (The specified value is retained as the subsequent default value.)
Arg14: Print_To_File: the (default) setting of the “Print to file” option in the dialog [FONT=&quot](default=False)[/FONT]
Arg15: Collate: the (default) setting of the “Collate” option in the dialog[FONT=&quot] (default=True)

[/FONT]
Code:
'Example:

Const PrtDlgSel_Selection    As Integer = 1
Const PrtDlgSel_ActiveSheets As Integer = 2
Const PrtDlgSel_Workbook     As Integer = 3
Const PrtDlgSel_List         As Integer = 4

Application.Dialogs(xlDialogPrint).Show Arg4:=1, _
                                        Arg12:=PrtDlgSel_ActiveSheets, _
                                        Arg15:=True
                                        
'i.e.                                   Copies:=1, _
                                        Selection:=PrtDlgSel_ActiveSheets, _
                                        Collate:=True

'NOTE: the "Selection" argument sets the dialog's "Print what" options.
[FONT=&quot]
[/FONT]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top