Can't trap error when checking for keys not in Collection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

For some reason when i try to remove a key from a Collection where that key
hasn't been added yet, i cannot trap the error when it occurs within an error
handler. All i get is a error dialog box that pops up that says "Invalid
procedure call or argument"

the code snippet is as follows:

On Error GoTo ERR_HANDLER
myCollection.Remove ("key1")
..
..
..
ERR_HANDLER:
..code here does not get executed when "key1" does not exist in myCollection.

How i can trap this error and continue processing?
 
I meant err.number instead of err.code
but mine was the wrong answer anyway see psmocko's reply.
 
Strange,

I copied your code and single stepped in VBA for excel 2003 SP1.

Same results as before.... code does NOT jump to errH when col.Remove s,
where s = "G".
 
Hi again

Problem solved. It appears that in the Tools->Options->General tab,
selecint Error Trapping to "break on all errors" causes this behaviour. I
selected "break on unhandled errors" and now the the code jumps to the ErrH
 

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

Back
Top