Q: Printing and CommonDialog
I am trying to print a form using the commondialog with ShowPrinter. When I run the app and click print, nothing happens. How do I get a form to print. and how does it show the message" printing to HP Laserject on LPT1?
Rick, rmunroe785@aol.com (RMunroe785)
A: Showing the commondialog doesn't make your application to print. You have to do it yourself. Look at the next code: Dim blnCancelPrint As Boolean 'you need this to check for the CancelButton in the commondialog Sub Command1_Click Const strDummy As String = "going to print something" Call ShowPrinter If blnCancelPrint Then Exit Sub Printer.Print strDummy Printer.EndDoc End Sub Sub ShowPrinter() Const ErrCancel = 32755 On Error GoTo ErrShowPrinter blnCancelPrint = False ' mdiMain.Dialoog1.CancelError = True ' mdiMain.Dialoog1.Flags = &H40& ' mdiMain.Dialoog1.PrinterDefault = True Form1.Dialoog1.ShowPrinter Exit Sub ErrShowPrinter: If Err = ErrCancel Then blnCancelPrint = True Exit Sub Else Resume Next End If End Sub Return