On Error Goto

R

ryguy7272

I've noticed some erratic behavior on our network printers and I'm trying to
trap any potential errors and allow a user to select another printer if there
is an error printing. This is my code:

On Error GoTo Below
Application.Dialogs(xlDialogPrinterSetup).Show
If Below = True Then
MsgBox "Please select another printer..."
End If

When I run the sub, I get a "Compile Error, Label not Defined" message. Can
someone please point my mistake.

Thanks,
Ryan--
 
O

Office_Novice

Lose the If then stuff .. you should be good to go.

Sub yoursub()
On Error GoTo Below
Application.Dialogs(xlDialogPrinterSetup).Show
Below:
MsgBox "Please select another printer..."

End sub
 
N

Norman Jones

Hi Ryguy,

How and where have you declared
Below.

Try posting the relevant routine.
 
R

ryguy7272

I'm using ON's suggestion and I just got an error. This line causes the error:
Application.Dialogs(xlDialogPrinterSetup).Show

It only happens with one particular printer...

I can't figure out why...
 
J

JLGWhiz

Where do you have "Below" defined? How does it equate to true?

If Err.Number <> 0 Then
MsgBox "Please select another printer..."
Application.Dialogs(xlDialogPrinterSetup).Show
End If
 
J

Jacques ALARDET

Hello

Attention, "on error goto" is not a same a "goto"

I propose :
Sub yoursub()
On Error GoTo E1
Application.Dialogs(xlDialogPrinterSetup).Show
S1: on error goto 0
MsgBox "Please select another printer..." exit sub
E1: resume S1
End sub
 
N

Norman Jones

Hi Ryguy,

=============
I'm using ON's suggestion and I just got an error. This line causes the
error:
Application.Dialogs(xlDialogPrinterSetup).Show

It only happens with one particular printer...

I can't figure out why...
=============


Try posting the relevant routine.
 
O

Office_Novice

try somthing like this, If an error occurs it will show the printer dialog box.

Sub Ry()
On Error GoTo Below
' Whatever you procedure is





Below:
Application.Dialogs(xlDialogPrinterSetup).Show

End Sub
 
R

ryguy7272

I tried that too, ON. It just keeps erroring, or going to the default
printer. The point for 'xlDialogPrinterSetup' line of code is to allow users
to actually...choose a printer. It just keeps giving me errors. Frustrating!

Most recent attempt was this:
Application.Dialogs(xlDialogPrinterSetup).Show
If Err.Number <> 0 Then
MsgBox "Please select another printer..."
End If

I didn't know if the 'xlDialogPrinterSetup' should go inside the if...end if.
Well, I tried JLG's code, as written, and that didn't wokr for me either.

Any other thoughts on this matter?
 
O

Office_Novice

Private Sub YourProc()
On Error GoTo Below
'Paste your code between here

'And Here
Below:
msgbox " please select another printer..."
Application.Dialogs(xlDialogPrinterSetup).Show
End Sub

If you only see the default printer maybe you need to set up other printers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top