PDA

Click to See Complete Forum and Search --> : Commondialog's print dialog


Forest Dragon
Dec 23rd, 1999, 06:50 PM
Hello!!!

Some questions about the commondialog control's print dialog:

1. How can I let the user to choose the start page and the end page?

2. How can I let the user to choose if he/she wants to collate the pages in the case of multiple copies?

3. How can I use the print dialog to select a printer and then set the crystalreports control to print to this printer?

Thanks!!!

MartinLiss
Dec 24th, 1999, 12:19 AM
Here is part of the answer:
Private Sub Command1_Click()

Dim BeginPage As Integer
Dim EndPage As Integer
Dim NumCopies As Integer
Dim Orientation As Integer
Dim Ndx As Integer
' Set Cancel to True.
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
' Display the Print dialog box.
CommonDialog1.ShowPrinter
' Get user-selected values from the dialog box.
BeginPage = CommonDialog1.FromPage
EndPage = CommonDialog1.ToPage
NumCopies = CommonDialog1.Copies
Orientation = CommonDialog1.Orientation
For Ndx = 1 To NumCopies
' Put code here to send data to your printer.
Next
Exit Sub
ErrHandler:
' User pressed Cancel button.
Exit Sub
End Sub


------------------
Marty

Forest Dragon
Dec 25th, 1999, 01:08 AM
Hello again!!!

Actually what I mean was, that when I call to the ShowPrinter method of the commondialog control, I get these options (StartPage, EndPage and Collate) hidden or disabled. I want to know how I can make them enabled and visible so the user can change their values.

I also want to know how I can get the printer's name and the driver's name from the commondialog control.

Thanks!!!

lemarquis
Dec 29th, 1999, 01:29 AM
When you use the common dialog's showprinter method, any change to the currently selected printer automatically updates the Printer object within VB. To change the printer when printing a CR report, use the report's SelectPrinter method and assign the required Printer properties to the SelectPrinter arguments.

Here are the 3 lines of code you need:

cdMain.ShowPrinter
rptBlotter.SelectPrinter Printer.DriverName, Printer.DeviceName, Printer.Port
rptBlotter.PrintOut False

Forest Dragon
Dec 29th, 1999, 01:49 AM
Thank you very much for your code!!!

But still, Does anyone know how to enable the start page, end page and collate options?

QWERTY
Dec 29th, 1999, 04:18 PM
Play around with these constants:
cdlPDNoPageNums
cdlPDPageNums
cdlPDCollate
I'm not sure how they work (I know that you have to use them with CommonDialog.Flags Property). I'm not going to try it now because it is 5:15 in the morning and I have to get some sleep now. Hope I was helpful.
Regards QWERTY

------------------
Visual Basic Programmer
------------------
PolComSoft
You will hear a lot about it.

Serge
Dec 29th, 1999, 09:09 PM
QWERTY is right. You would have to use these constants with Flags property:

Private Sub Command1_Click()
With CommonDialog1
.Flags = cdlPDNoPageNums Or cdlPDPageNums Or cdlPDCollate
.ShowPrinter
End With
End Sub


Check out VB's help or MSDN library for complete explanation of these constants.

------------------

Serge

Software Developer
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)

Jorgen
Jun 4th, 2001, 02:06 PM
Forrest Dragon

I have the same problem as you. I want to enable the option button for selecting the printing from page to page. Did you ever solve the problem?

Jorgen