Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default error control

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default error control

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

Graeme wrote:
*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


--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2007 Form Control/ActiveX Control font difference Nikko963 Excel Discussion (Misc queries) 0 April 15th 09 04:21 PM
Control Box Error ynissel Excel Discussion (Misc queries) 1 June 3rd 05 10:57 PM
Error 50290: Error writing to Worksheet while using an ActiveX Control emblair3 Excel Programming 3 February 24th 04 06:03 PM
webbrowser control error No Name Excel Programming 0 November 18th 03 05:18 AM
ActiveX Error w/Calendar Control Ron Armstrong Excel Programming 0 October 24th 03 01:25 AM


All times are GMT +1. The time now is 10:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"