Selasa, 22 April 2014

Re: [ExcelVBA] EXCEL :: When the User clicks 'No', the Macro should stop

 

I tried it in a simple macro and it worked.
(although the  VbMsgBoxResult is not required)
 
If not (vbYes = MsgBox("Are you sure you want to cancel the process?", vbYesNo + vbDefaultButton2 + vbQuestion, "Cancel Process?")) Then
Exit Sub
End If
 
(however, is your logic correct?
your question:
Are you sure you want to cancel the process?
 
if the user answers "yes", then he's saying he IS sure he wants to cancel.
but you have it aborting the cancellation if he says he wants to cancel?
 
Try setting a breakpoint at the "If Not..." statement.
 
It may be that your button macro is being called repeatedly.
(so the macro itself is working, but it just keeps restarting)
 
 
Paul
-----------------------------------------
"Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can." - John Wesley
-----------------------------------------

From: Satheesh Kumar <satheesh_it47@yahoo.com>
To: ExcelVBA@yahoogroups.com
Sent: Tuesday, April 22, 2014 4:52 AM
Subject: [ExcelVBA] EXCEL :: When the User clicks 'No', the Macro should stop
 
Hi
 
I have created the progress bar in one of my tool using Forms, if the User clicks the Cancel button in the progress bar, it should prompt the User to confirm the cancellation with Yes and No button, when No button got pressed, the macro should stop at the point. Below is my code which I tried, this code got hung in showing the prompt, not working as I expects, Help me here..
 
Private Sub btnCancel_Click()    If Not (VbMsgBoxResult.vbYes = MsgBox("Are you sure you want to cancel the process?", vbYesNo + vbDefaultButton2 + vbQuestion, "Cancel Process?")) Then        Exit Sub    End If        m_canceled = True    btnCancel.Enabled = False    btnCancel.Caption = "Cancelling..."End Sub
 
Thanks
Satheesh Kumar S

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar