Can I programmatically simulate clicking the 'stop macro' button in the VBE?

A

Alan

Can I simulate the clicking of the stop button in the VB Editor using
VBA?

Thanks,

Alan.
 
T

Tom Ogilvy

I have never used the stop button, but if you want to just stop code
execution, use Ctrl + C, Esc, or Break key.
 
M

Michel Pierron

Hi Alan;
You can try:

DoEvents
Application.VBE.CommandBars.FindControl(ID:=228).Execute

MP
 
T

Tom Ogilvy

Sorry, misread your post. (I actually couldn't find a stop button, but
Michael interpreted it as the Reset button). What are you trying to
achieve.
 
A

Alan

Tom Ogilvy said:
Sorry, misread your post. (I actually couldn't find a stop button,
but Michael interpreted it as the Reset button). What are you
trying to achieve.

Hi Tom,

I have a spreadsheet with some event driven code (worksheet change
event specifically). This is also a shared workbook.

Occasionally, a user gets a 'Document Not Saved' message when they try
to save. I believe that this is being caused by an event driven code
somehow hanging or getting into some kind of loop, stopping the user
saving.

We are reviewing the code, but in the meantime, I wanted to give the
users a way to effectively click on 'reset' in the VBE (without having
to know anything about the VBE), to stop / reset any runnning code,
and effect a save.

I have used the line supplied by Michel
(amended to include a
'Do Events' after it as you suggested in reply to that posting, so I
will see if that gets the users saving again next time it occurs.

Thanks,

Alan.
 

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

Top