LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Junior Member
 
Posts: 1
Default

Quote:
Originally Posted by TonyD View Post
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
Here's the complete reference info on xlDialogPrint:

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 (default=False)
Arg15: Collate: the (default) setting of the “Collate” option in the dialog (default=True)

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.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Testing a group of option buttons for a selection. Amber_D_Laws[_71_] Excel Programming 1 February 15th 06 09:17 PM
Controlling the 'cancel' button in xldialogprint JNW Excel Programming 1 September 15th 05 09:08 PM
Tools - Option - "move selection after enter" jules75 Excel Worksheet Functions 0 August 17th 05 10:56 PM
Other option of InputBox for range selection yogee Excel Programming 7 April 23rd 05 10:47 AM
VBA : xlDialogPrint function Gilbert Aponte[_2_] Excel Programming 0 October 15th 03 12:23 AM


All times are GMT +1. The time now is 08:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"