|
-
Jun 26th, 2000, 09:57 PM
#1
Thread Starter
New Member
Hi,
I need some help hoping it wont be to dificult to do, basically from a printer dialog box I need to grab the name of the selected printer not the default, so Im using the cdlPDSelection Flag and am getting the dialogs hDC property back but I have no idea what this is or how to use it please help.
Malal
-
Jun 27th, 2000, 01:39 AM
#2
Addicted Member
You can try the following code, name your Print Command Buttton cmdPrint then:
Code:
Private Sub cmdPrint_Click()
On Error GoTo ErrHandler
CommonDialog1.Flags = cdlPDNoSelection Or _
cdlPDNoPageNums Or _
cdlPDHidePrintToFile Or _
cdlPDUseDevModeCopies
'show printer dialog
CommonDialog1.PrinterDefault = False
CommonDialog1.CancelError = True
CommonDialog1.ShowPrinter
'Put your Print Code here
Printer.Print " Hello"
Printer.EndDoc 'Close the Document & stop Printing
'Bypass the Error associated with Cancel
Exit Sub
ErrHandler:
Dim RetVal As Integer
RetVal = MsgBox("Canceling Print Job", 0, "Printer ")
Exit Sub
End Sub
The above will allow you to select a printer from the Print
Dialog Box.
The following will allow you to find a certain printer
in the printer collection:
The Printers collection enables you to query the available printers so you can specify a default printer for your application. For example, you may want to find out which of the available printers uses a specific printer driver. The following code searches all available printers to locate the first printer with its page orientation set to Portrait, then sets it as the default printer:
Code:
Dim X As Printer
For Each X In Printers
If X.Orientation = vbPRORPortrait Then
' Set printer as system default.
Set Printer = X
' Stop looking for a printer.
Exit For
End If
Next
You designate one of the printers in the Printers collection as the default printer by using the Set statement. The preceding example designates the printer identified by the object variable X, the default printer for the application.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|