cancel a macro in progress

C

cayce

Are there shortcut keys that will safely cancel a macro in progress? I am
speaking of macros that ask the user for input (i.e. a number or date).
Sometimes the people I support realize they chose to run the wrong macro or
otherwise want to stop the one they started. I want to give them a safe way
to cancelling the macro in progress that will still be available to them at a
future time.

Any ideas would be appreciated.
 
J

Jay Freedman

Are there shortcut keys that will safely cancel a macro in progress? I am
speaking of macros that ask the user for input (i.e. a number or date).
Sometimes the people I support realize they chose to run the wrong macro or
otherwise want to stop the one they started. I want to give them a safe way
to cancelling the macro in progress that will still be available to them at a
future time.

Any ideas would be appreciated.

Usually the shortcut Ctrl+Break will stop a macro, particularly if
it's waiting for input. You get a message box asking whether to end
the macro or enter debug mode.
 
D

David Sisson

Sometimes the people I support ...

If you are the author of the macro then you can always add error
handling.

Sub main()

Dim Response As String

Answer1:
Response = InputBox("Enter Name", "Enter QUIT to Cancel")

If UCase(Response) = "QUIT" Then
End
ElseIf Len(Response) = 0 Then
MsgBox ("Entry can't be empty")
GoTo Answer1
End If

MsgBox Response

End Sub
 
C

cayce

thanks for the suggestion David but I am not the author of the macro, just a
user. Jay's suggestion above about Ctrl+ break is what I was looking for.

thanks to both of you for the quick response.
 
B

Bryan

Hey David,

As with Cayce's response below, I like simplicity. However I did not want
my users trying to work with "breaking" the code. I simply used:

If NumCopies = Cancel then End

NumCopies being my first messagebox. The code simply stops with no popup
requiring another response and also nothing for my users to remember.

Bryan
 

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