ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Halt / Stop processing when a user selects Cancel (https://www.excelbanter.com/excel-programming/413111-halt-stop-processing-when-user-selects-cancel.html)

scott56hannah

Halt / Stop processing when a user selects Cancel
 
Hi,

I have a routine that sends a group of emails based on a user action.

The user is presented with a Form that reports on the progress of sending
those emails...

I want to be able to give the user the option to Halt / Stop the sending of
those emails at anytime.

I have already tried a number of methods to get this working, but although I
am able to stop the actual processing the send mail routine in the back
ground continues to process.

The problem I think is that when the "Cancel" button is clicked it takes
control from the background process that has been called to send the mail....

Is there anyway I am able to stope background processing in Excel when this
cancel button is called.....and in addition to continue that processing in
the same place if the user elects to continue

I don't know if this is too confusing for anyone to help...but it would be
appreciated

Scott

Peter T

Halt / Stop processing when a user selects Cancel
 
This is just for ideas, it's unlikely you'd want to do it quite like this
(put two buttons on a form) -

Private mbDoStuff As Boolean

Private Sub CommandButton1_Click() ' cancel button

If mbDoStuff Then
If MsgBox("Abort", vbYesNo) = vbYes Then
mbDoStuff = False
End If
End If

If Not mbDoStuff Then Unload Me

End Sub

Private Sub CommandButton2_Click()
Dim d As Double, dev As Long
mbDoStuff = True

dev = -1
Do While d < 123456 And mbDoStuff
d = Range("A1").Value
d = d + 1
Range("A1").Value = d
Me.Caption = d

If d dev Then
DoEvents
dev = dev + 100
'aim to allow a DoEvents say every 0.1 to 0.5 sec's
' but not in every "quick" loop
End If
Loop

MsgBox d
End Sub


Generally aim to allow a DoEvents say every 0.1 to 0.5 seconds. No need to
check in every loop unless each loop involves a lengthy process, like
sending emails.

Regards,
Peter T



"scott56hannah" wrote in message
...
Hi,

I have a routine that sends a group of emails based on a user action.

The user is presented with a Form that reports on the progress of sending
those emails...

I want to be able to give the user the option to Halt / Stop the sending

of
those emails at anytime.

I have already tried a number of methods to get this working, but although

I
am able to stop the actual processing the send mail routine in the back
ground continues to process.

The problem I think is that when the "Cancel" button is clicked it takes
control from the background process that has been called to send the

mail....

Is there anyway I am able to stope background processing in Excel when

this
cancel button is called.....and in addition to continue that processing in
the same place if the user elects to continue

I don't know if this is too confusing for anyone to help...but it would be
appreciated

Scott




Nigel[_2_]

Halt / Stop processing when a user selects Cancel
 
I would use a function to mail one address at a time, then after each call
you can intercept the main calling program. I would not use 'Cancel' to
pause the process, 'Pause/Continue' would be better, that requires some
extra logic to store the current progress and resume at the last completed
mailing.

Hope this helps

--

Regards,
Nigel




"scott56hannah" wrote in message
...
Hi,

I have a routine that sends a group of emails based on a user action.

The user is presented with a Form that reports on the progress of sending
those emails...

I want to be able to give the user the option to Halt / Stop the sending
of
those emails at anytime.

I have already tried a number of methods to get this working, but although
I
am able to stop the actual processing the send mail routine in the back
ground continues to process.

The problem I think is that when the "Cancel" button is clicked it takes
control from the background process that has been called to send the
mail....

Is there anyway I am able to stope background processing in Excel when
this
cancel button is called.....and in addition to continue that processing in
the same place if the user elects to continue

I don't know if this is too confusing for anyone to help...but it would be
appreciated

Scott



scott56hannah

Halt / Stop processing when a user selects Cancel
 
Nigel,

Yes that's what I am trying to do....but I have found that when the
Pause/Continue button is pressed it takes control of the form logic from the
SendMail routine that is underway....how can I return control of the logic to
that process ?

Scott

"Nigel" wrote:

I would use a function to mail one address at a time, then after each call
you can intercept the main calling program. I would not use 'Cancel' to
pause the process, 'Pause/Continue' would be better, that requires some
extra logic to store the current progress and resume at the last completed
mailing.

Hope this helps

--

Regards,
Nigel




"scott56hannah" wrote in message
...
Hi,

I have a routine that sends a group of emails based on a user action.

The user is presented with a Form that reports on the progress of sending
those emails...

I want to be able to give the user the option to Halt / Stop the sending
of
those emails at anytime.

I have already tried a number of methods to get this working, but although
I
am able to stop the actual processing the send mail routine in the back
ground continues to process.

The problem I think is that when the "Cancel" button is clicked it takes
control from the background process that has been called to send the
mail....

Is there anyway I am able to stope background processing in Excel when
this
cancel button is called.....and in addition to continue that processing in
the same place if the user elects to continue

I don't know if this is too confusing for anyone to help...but it would be
appreciated

Scott




All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com