Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
AL AL is offline
external usenet poster
 
Posts: 37
Default stop execution

2nd post please help
In a form I put a commmandbutton with cancel and
default=true so when the program is running I could stop
the execution, but it does not work, I try click and
mouse-up subs. It only works after the code has finish
executing. What am I doing wrong? Can you give me an
example of how can I accomplish this task?
Thanks in advance
Al
..


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default stop execution

Al,

Your code is executing, and during execution, you click on the Cancel
button. Your form is responding to events in the sequence in which they
occur.

Check out the DOEVENTS function.

Steve
"al" wrote in message
...
2nd post please help
In a form I put a commmandbutton with cancel and
default=true so when the program is running I could stop
the execution, but it does not work, I try click and
mouse-up subs. It only works after the code has finish
executing. What am I doing wrong? Can you give me an
example of how can I accomplish this task?
Thanks in advance
Al
.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default stop execution

What is your code doing that you want to cancel? Is it looping over a range
of values? It would help if you would post an example.

"al" wrote in message
...
2nd post please help
In a form I put a commmandbutton with cancel and
default=true so when the program is running I could stop
the execution, but it does not work, I try click and
mouse-up subs. It only works after the code has finish
executing. What am I doing wrong? Can you give me an
example of how can I accomplish this task?
Thanks in advance
Al
.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default stop execution

Create a form with two buttons and drop this into its code module.

Option Explicit
Private mCancel As Boolean

Private Sub CommandButton1_Click()
Dim n
Me.MousePointer = fmMousePointerHourGlass
For n = 1 To 10000
'long running process
Debug.Print n
DoEvents
If mCancel = True Then Exit For
Next n
mCancel = False
Me.MousePointer = fmMousePointerDefault
End Sub

Private Sub CommandButton2_Click()
mCancel = True
End Sub

Private Sub UserForm_Initialize()
mCancel = False
End Sub

"al" wrote in message
...
2nd post please help
In a form I put a commmandbutton with cancel and
default=true so when the program is running I could stop
the execution, but it does not work, I try click and
mouse-up subs. It only works after the code has finish
executing. What am I doing wrong? Can you give me an
example of how can I accomplish this task?
Thanks in advance
Al
.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop window saying code execution interrupted at startup? Jerry07 Excel Discussion (Misc queries) 1 August 15th 09 05:16 PM
AUTOMATIC EXECUTION VB_User Excel Discussion (Misc queries) 5 December 28th 07 11:48 PM
stop code execution with button Al ramirez Excel Programming 0 October 1st 04 06:27 AM
Execution Error Craig[_8_] Excel Programming 0 September 7th 04 05:12 PM
stop code execution al ramirez Excel Programming 1 August 26th 04 03:45 AM


All times are GMT +1. The time now is 10:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"