Run time Error when there is no Printer Installed!

kelfar
09-03-2003, 01:14 AM
Hi,


My program runs perfect on my machine windows xp pro. When my friend tried to run the .exe version of the program on his machine he got the two following errors:
"run-time error '482'"

"Printer error"

There was no printer installed when he installed it then the problem has gone. Any advice what should I do so the program run whither you have printer or not.

I have used the Code from the msdn website to print with margins.

Thinker
09-03-2003, 10:39 AM
I haven't checked this, but the first thing I would try is to see if the
Printer object is Nothing. I would expect that if there is no printer
installed it would be.

kelfar
09-03-2003, 10:47 AM
QUOTEPOST='Thinker']I haven't checked this, but the first thing I would try is to see if the
Printer object is Nothing. I would expect that if there is no printer
installed it would be.[/QUOTEPOST]



Yes, it was bad design by microsoft. They have initialized the printer in Form_Load like this.

Printer.Orientation = vbPRORPortrait 'vbPRORLandscape

I deleted it and only use Commondialog to get the orientation. What do you think?

Private Sub FilePrint_Click()

'EditSelect_Click
CommonDialog1.Flags = cdlPDSelection + cdlPDReturnDC + cdlPDAllPages

On Error GoTo FileError:
CommonDialog1.CancelError = True
CommonDialog1.ShowPrinter

PrintRTF RichTextBox1, AnInch + 400, AnInch, AnInch + 400, AnInch


'RichTextBox1.SelPrint CommonDialog1.hdc

Exit Sub

FileError:
If Err.Number = cdlCancel Then Exit Sub
MsgBox "Unknown error while printing file" & CommonDialog1.FileName

'Print the contents of the RichTextBox with a one inch margin




End Sub

[

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum