Thread: error trapping
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
libby libby is offline
external usenet poster
 
Posts: 96
Default error trapping

Thanks guys!
-----Original Message-----
On Error goto ErrHandler
Application.ActivePrinter = listbox1.value
Exit Sub
ErrHandler:
msgbox err.number & vbNewLine & _
err.Description & vbNewline & vbNewLine & _
"This printer is not available"
End Sub

--
Regards,
Tom Ogilvy



libby wrote in

message
...
Hi

Well, there are many networked printers in our office

and
I have created a form which has 5 of the most common

ones
in it. When the user selects one, a label displays the
location of the printer in the office.
I've also so set it so that if the Active Printer for a
particular pc isn't in the listbox, then it's added to

it.

There is a "Change" button on the form which changes the
active printer to one which the user has selected.

It all works fine if you have all the printers mapped to
your pc, but if you try and change the active printer to
one which is not mapped to your pc, then the run-time
error occurs.
I need to either map the printer (which I don't think is
possible)
or trap this error and go to an error handler which
displays an appropriate message.

The code for the Change button is
Application.ActivePrinter = listbox1.value

I can post more code if need be, but don't have it to

hand
at present.

-----Original Message-----
post all of your code relating to this

--
Don Guillett
SalesAid Software

"libby" wrote in

message
...
Hi
I'm having real trouble trapping this error.

I have a sub where the active printer is changed
Application.ActivePrinter = ListBox1.value

if the printer is networked then it works fine, but

if
it
isn't I get a run-time error 1004
Method 'ActivePrinter' of object'_Application' failed

Is there any way I can user On Error GoTo

Errorhandler
to
display the message "Printer Not Mapped" if this

happpens?

Thanks in advance
Libby (xl97)


.



.