thebug
Mar 13th, 2001, 08:38 AM
Browsing through the forums I saw that a common problen is printing a document to a printer without making that printer the default printer for Windows.
I have the same question, so please look at my code.
This is my code:
If Not (ActiveForm Is Nothing) Then
With dialogFile
.Flags = cdlPDAllPages Or _
cdlPDDisablePrintToFile Or _
cdlPDNoPageNums Or _
cdlPDNoWarning Or _
cdlPDReturnDC Or _
cdlPDNoSelection
.PrinterDefault = True
.ShowPrinter
Printer.Copies = .Copies
Printer.Orientation = .Orientation
ActiveForm.myPrint
End With
End If
The function "myPrint" uses the Printer object. The problem is that every time I select a printer from the common dialog, VB correctly prints all the output to the selected printer, but sets that printer as deafult printer forever!
I'd like to have a code like this:
If Not (ActiveForm Is Nothing) Then
With dialogFile
.Flags = cdlPDAllPages Or _
cdlPDDisablePrintToFile Or _
cdlPDNoPageNums Or _
cdlPDNoWarning Or _
cdlPDReturnDC Or _
cdlPDNoSelection
.PrinterDefault = False
.ShowPrinter
Printer.Copies = .Copies
Printer.Orientation = .Orientation
ActiveForm.myPrint (.hDC)
End With
End If
Now the PrinterDefault property of the common dialof is set to false so that when i select the printer VB doesn't change the default printer, but the function myPrint prints to a specific HDC: the one selected in the common dialog.
Any help on how to implement the myPrint (hDC) function? Maybe through API calls?
I have the same question, so please look at my code.
This is my code:
If Not (ActiveForm Is Nothing) Then
With dialogFile
.Flags = cdlPDAllPages Or _
cdlPDDisablePrintToFile Or _
cdlPDNoPageNums Or _
cdlPDNoWarning Or _
cdlPDReturnDC Or _
cdlPDNoSelection
.PrinterDefault = True
.ShowPrinter
Printer.Copies = .Copies
Printer.Orientation = .Orientation
ActiveForm.myPrint
End With
End If
The function "myPrint" uses the Printer object. The problem is that every time I select a printer from the common dialog, VB correctly prints all the output to the selected printer, but sets that printer as deafult printer forever!
I'd like to have a code like this:
If Not (ActiveForm Is Nothing) Then
With dialogFile
.Flags = cdlPDAllPages Or _
cdlPDDisablePrintToFile Or _
cdlPDNoPageNums Or _
cdlPDNoWarning Or _
cdlPDReturnDC Or _
cdlPDNoSelection
.PrinterDefault = False
.ShowPrinter
Printer.Copies = .Copies
Printer.Orientation = .Orientation
ActiveForm.myPrint (.hDC)
End With
End If
Now the PrinterDefault property of the common dialof is set to false so that when i select the printer VB doesn't change the default printer, but the function myPrint prints to a specific HDC: the one selected in the common dialog.
Any help on how to implement the myPrint (hDC) function? Maybe through API calls?