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

Run-time error '1004':

Application-defined or object-defined error



this appears when no Print_Area is defined



ActiveSheet.Names("Print_Area").Delete

ActiveSheet.Names("Print_Titles").Delete



I think I have seen that an error message can be turned off before a likely
error and on again after - dangerous if not carefully used.



How should I handle this possible error?



Francis Hookham


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Run-time error

You are correct taht error handling should be used judisciously. That being
said what you are trying to do can be handled safely something like this

OnError Resume Next
ActiveSheet.Names("Print_Area").Delete
ActiveSheet.Names("Print_Titles").Delete
On Error Goto 0

--
HTH...

Jim Thomlinson


"Francis Hookham" wrote:

Run-time error '1004':

Application-defined or object-defined error



this appears when no Print_Area is defined



ActiveSheet.Names("Print_Area").Delete

ActiveSheet.Names("Print_Titles").Delete



I think I have seen that an error message can be turned off before a likely
error and on again after - dangerous if not carefully used.



How should I handle this possible error?



Francis Hookham



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Run-time error

You had me guessing for s minute or two - I pasted in your code without
looking carefully at it.

'OnError' in first line! All's well now - many thanks.

Francis

"Jim Thomlinson" wrote in message
...
You are correct taht error handling should be used judisciously. That
being
said what you are trying to do can be handled safely something like this

OnError Resume Next
ActiveSheet.Names("Print_Area").Delete
ActiveSheet.Names("Print_Titles").Delete
On Error Goto 0

--
HTH...

Jim Thomlinson


"Francis Hookham" wrote:

Run-time error '1004':

Application-defined or object-defined error



this appears when no Print_Area is defined



ActiveSheet.Names("Print_Area").Delete

ActiveSheet.Names("Print_Titles").Delete



I think I have seen that an error message can be turned off before a
likely
error and on again after - dangerous if not carefully used.



How should I handle this possible error?



Francis Hookham





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Run-time error

Error handler (OnError) is ok in this instance because you are ok if it fails
and there is nothing to worry about if it does.

Time to hop on my soap box... The error handler is not there to address poor
code. IMO if you can avoid an error you are much better off than trying to
deal with it after the fact. That being said there are times when your code
may generate errors because you are looking for something that may or may not
exist (such as in your case). You can use the error handler here if either
you don't care if the code fails (such as your case) or you are trying to set
an object that you will check later to see if it was successfully created.
--
HTH...

Jim Thomlinson


"Francis Hookham" wrote:

You had me guessing for s minute or two - I pasted in your code without
looking carefully at it.

'OnError' in first line! All's well now - many thanks.

Francis

"Jim Thomlinson" wrote in message
...
You are correct taht error handling should be used judisciously. That
being
said what you are trying to do can be handled safely something like this

OnError Resume Next
ActiveSheet.Names("Print_Area").Delete
ActiveSheet.Names("Print_Titles").Delete
On Error Goto 0

--
HTH...

Jim Thomlinson


"Francis Hookham" wrote:

Run-time error '1004':

Application-defined or object-defined error



this appears when no Print_Area is defined



ActiveSheet.Names("Print_Area").Delete

ActiveSheet.Names("Print_Titles").Delete



I think I have seen that an error message can be turned off before a
likely
error and on again after - dangerous if not carefully used.



How should I handle this possible error?



Francis Hookham






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Run-time error

Just adding to Jim's excellent response, it is *critical* to understand that
an On Error does NOT in any way fix the error. I've seen more code than I
care to remember in which the original programmer assumed that On Error
would somehow fix the problem. It doesn't. It just ignores it.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Jim Thomlinson" wrote in message
...
Error handler (OnError) is ok in this instance because you are ok if it
fails
and there is nothing to worry about if it does.

Time to hop on my soap box... The error handler is not there to address
poor
code. IMO if you can avoid an error you are much better off than trying to
deal with it after the fact. That being said there are times when your
code
may generate errors because you are looking for something that may or may
not
exist (such as in your case). You can use the error handler here if either
you don't care if the code fails (such as your case) or you are trying to
set
an object that you will check later to see if it was successfully created.
--
HTH...

Jim Thomlinson


"Francis Hookham" wrote:

You had me guessing for s minute or two - I pasted in your code without
looking carefully at it.

'OnError' in first line! All's well now - many thanks.

Francis

"Jim Thomlinson" wrote in
message
...
You are correct taht error handling should be used judisciously. That
being
said what you are trying to do can be handled safely something like
this

OnError Resume Next
ActiveSheet.Names("Print_Area").Delete
ActiveSheet.Names("Print_Titles").Delete
On Error Goto 0

--
HTH...

Jim Thomlinson


"Francis Hookham" wrote:

Run-time error '1004':

Application-defined or object-defined error



this appears when no Print_Area is defined



ActiveSheet.Names("Print_Area").Delete

ActiveSheet.Names("Print_Titles").Delete



I think I have seen that an error message can be turned off before a
likely
error and on again after - dangerous if not carefully used.



How should I handle this possible error?



Francis Hookham









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Run-time error

In message
at 11:54:00 on Fri, 14 Sep 2007, Jim Thomlinson
wrote
Time to hop on my soap box... The error handler is not there to address poor
code. IMO if you can avoid an error you are much better off than trying to
deal with it after the fact. That being said there are times when your code
may generate errors because you are looking for something that may or may not
exist (such as in your case).

A classic example is finding out the ubound of an uninitialised dynamic
array
--
Mike News
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Run-time error

Apologies - time flies - I did not thank you - many thanks

Francis


"Jim Thomlinson" wrote in message
...
You are correct taht error handling should be used judisciously. That
being
said what you are trying to do can be handled safely something like this

OnError Resume Next
ActiveSheet.Names("Print_Area").Delete
ActiveSheet.Names("Print_Titles").Delete
On Error Goto 0

--
HTH...

Jim Thomlinson


"Francis Hookham" wrote:

Run-time error '1004':

Application-defined or object-defined error



this appears when no Print_Area is defined



ActiveSheet.Names("Print_Area").Delete

ActiveSheet.Names("Print_Titles").Delete



I think I have seen that an error message can be turned off before a
likely
error and on again after - dangerous if not carefully used.



How should I handle this possible error?



Francis Hookham





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
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Run Time 1004 Error: Application or Object Difine Error BEEJAY Excel Programming 0 October 17th 06 10:45 PM
Conditional Formatting - Run Time Error '13' Type Mismatch Error ksp Excel Programming 0 July 11th 06 07:06 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM


All times are GMT +1. The time now is 06:09 PM.

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

About Us

"It's about Microsoft Excel"