error control

G

Graeme

I have just written my first VBScript/Macro that does
some cool manipulation of data. How do I get the script
to exit gracefully if something is wrong, or out of place?

For example:

I have a button attached to this script for printing:

Application.ActivePrinter = "Acrobat PDFWriter on
LPT1:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1,
ActivePrinter:= _
"Acrobat PDFWriter on LPT1:"



If I hit cancel in the print screen the script will stop
and go into debug. Is there a generic script "If error
then....."

Thanks for the helping,
Graeme
 
K

KJTFS

put
on error goto CANCEL
at the begining of your code

then at the bottom put
exit sub ' need this so if no errors program doesnt execute CANCEL
CANCEL:
'Any clean up code here
exit sub

for more info on error checking do a search for it, i am sure there i
a lot written about it.

Keith
www.kjtfs.com
 

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