Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppressing debug messages possible? 1

Status
Not open for further replies.

gumbald

Technical User
Apr 6, 2006
16
I've managed to create a web based printer chooser, relying on multiple text files, messy but will do just fine (it's not my job to maintain it...)

However, if the user tries to add a printer that isn't available (ie. the computer isn't turned on), I get the error message saying the printer could not be found, and asking if I want to debug. I'm expecting the dumb user, so can I intercept this message and output a friendlier one telling them to choose again?

Apologies if this again is obvious, my entire VBScript knowledge was gained from the internet last week.
 
Add a line near the add line.
[tt]on error resume next[/tt]
I do not recommend it bare like that. (If it is bare like that, it is for those admins who fear their job be at stake if error turns up.) If your script is not much different from you last thread, then something like this.
[tt]
on error resume next
netPrinter.AddWindowsPrinterConnection UNCpath
if err.number<>0 then
msgbox "Cannot establish the printer connection" & vbcrlf & "error: &H" & hex(err.number) & vbcrlf & err.description
err.clear
end if
on error goto 0
[/tt]
 
Thanks, much tidier. Just another thing to add on though, it finishes the sub whether error raised or not. On return from the sub, it quits out. How can I add a check as to whether an error was raised, and therefore whether it should quit out?

Jamie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top