• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Raise an error generate an automation error

Lolo

Member
Hello,

I have a question about error management in vba.

I have a subroutine That have error management, and launch an err.raise.

When this sub is called from another sub, executed from a button, and then an error occurs, Everything is fine, my error message is displayed.
But when same sub is used in an event pivottableupdate or from a keyboard shortcut I have set, the message 'automation error' appears instead of my error message.

After some researches seems in some cases an err.raise cannot be executed.
I thought it was always when a sub is launched from an excel event, but it works fine in some events Like worksheet_change but not in pivottableupdate for example.

Is any one have some feedback or experience or resource to share on it and could give me some advice on how I could manage correclty an error raising which could work in all cases?


Hope I m clear, thank a lot. :)
 
Hello,

thank you for your answer. I will take a look on it.

However, I have found the origin of the issue.
It is when I call a sub located in another worksheet, from a module or another worksheet. In this case the Err.raise returns 'Error Automation' instead of my error message.

See the file in attached, I try to explain the issue.

Seems we cannot call a sub located on antoehr worksheet. Or it works, but there is an issue with Err.raise function :(
 

Attachments

  • test_Err_Mgt2.xlsm
    31 KB · Views: 1
Back
Top