I'm trying to come up with a standard pattern for VBA error handling with nested function that at least doesn't lose information, and I'm having insane amounts of difficulty. I started with

Please Login or Register  to view this content.
This basically works fine, though of course it's equivalent to leaving the default On Error Goto 0 in place. Then, I added some cleanup code in the handler block:

Please Login or Register  to view this content.
This doesn't work, because the cleanup code (sometimes) clears Err. So, I tried saving and restoring Err:

Please Login or Register  to view this content.
This doesn't work either, because the savedErr = Err assignment doesn't make a copy, and there doesn't appear to be a way to copy Err. So, I went with something more primitive:

Please Login or Register  to view this content.
This doesn't work either, and this is the one that blows my mind. When I do this, the error number is preserved and received properly in the calling function, but all the other error information is lost. Specifically, Err.Description reverts to the standard description string for the number given, which is normally "Automation Error" for anything in the vbObjectError range. Even if I explicitly do a
Please Login or Register  to view this content.
, it's still lost.

Can anyone explain this behavior? Can anyone suggest an error-handling pattern that works? Can anyone explain how it is that this godawful language still exists?

Thanks,
Aaron