<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/exiting-a-macro-while-running/m-p/299769#M68093</link>
    <description>I'm sure this isn't the cleanest answer, but it's been a long day...&lt;BR /&gt;
&lt;BR /&gt;
I would do something similar to Sean.  In your module in ThisDrawing, put&lt;BR /&gt;
code such as:&lt;BR /&gt;
&lt;BR /&gt;
Public boolFormCanceled as boolean&lt;BR /&gt;
'until user actually pushes OK button, assume the user cancels&lt;BR /&gt;
boolFormCanceled = True&lt;BR /&gt;
myForm.show&lt;BR /&gt;
if boolFormCanceled = true then Exit Sub&lt;BR /&gt;
&lt;BR /&gt;
In your userform, if you have an OK button that the user clicks to keep&lt;BR /&gt;
going (assuming it's named btnOK), put the following:&lt;BR /&gt;
&lt;BR /&gt;
Private Sub btnOK_Click()&lt;BR /&gt;
    boolFormCanceled = False&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
This way, the only way the user can keep the program going is to use the OK&lt;BR /&gt;
button.&lt;BR /&gt;
&lt;BR /&gt;
Good luck</description>
    <pubDate>Tue, 26 Nov 2002 14:04:53 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2002-11-26T14:04:53Z</dc:date>
    <item>
      <title>Exiting a macro while running</title>
      <link>https://forums.autodesk.com/t5/vba-forum/exiting-a-macro-while-running/m-p/299767#M68091</link>
      <description>I have made a VB SubRoutine in ThisDrawing that call a Userform. When the user click the X button or my cancel button i want my whole program to stop (the routine in ThisDrawing) what is the command i must use to do this? Thanks, Gis</description>
      <pubDate>Mon, 25 Nov 2002 07:28:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/exiting-a-macro-while-running/m-p/299767#M68091</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-11-25T07:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Exiting a macro while running</title>
      <link>https://forums.autodesk.com/t5/vba-forum/exiting-a-macro-while-running/m-p/299768#M68092</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I am a rank beginner so be careful of the value you place on my suggestions.&lt;BR /&gt;
&lt;BR /&gt;
Under my "Private Sub CmdCancel_Click()"  (CmdCancel=the name of my cancel&lt;BR /&gt;
button) I set a public boolean variable "Cancel = True" this is then trapped&lt;BR /&gt;
this in my code when control is passed back to the main subroutine. This&lt;BR /&gt;
works when you press the cancel button. For this to work with the escape key&lt;BR /&gt;
you need to set the Cancel property of a command button named "Cancel" or&lt;BR /&gt;
"Close" to True (then hitting the ESC key will be the same as clicking that&lt;BR /&gt;
button).&lt;BR /&gt;
&lt;BR /&gt;
I do not know how to trap the user clicking the X button. I assume that you&lt;BR /&gt;
could set Cancel = True before you call the userform and set Cancel = false&lt;BR /&gt;
if the user clicks the X button.&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps.&lt;BR /&gt;
&lt;BR /&gt;
Sean&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"CIA_GIS" &lt;TESSIER_GHISLAIN&gt; wrote in message&lt;BR /&gt;
news:f127141.-1@WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; I have made a VB SubRoutine in ThisDrawing that call a Userform. When the&lt;BR /&gt;
user click the X button or my cancel button i want my whole program to stop&lt;BR /&gt;
(the routine in ThisDrawing) what is the command i must use to do this?&lt;BR /&gt;
Thanks, Gis&lt;BR /&gt;
&amp;gt;&lt;/TESSIER_GHISLAIN&gt;</description>
      <pubDate>Tue, 26 Nov 2002 08:38:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/exiting-a-macro-while-running/m-p/299768#M68092</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-11-26T08:38:14Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/exiting-a-macro-while-running/m-p/299769#M68093</link>
      <description>I'm sure this isn't the cleanest answer, but it's been a long day...&lt;BR /&gt;
&lt;BR /&gt;
I would do something similar to Sean.  In your module in ThisDrawing, put&lt;BR /&gt;
code such as:&lt;BR /&gt;
&lt;BR /&gt;
Public boolFormCanceled as boolean&lt;BR /&gt;
'until user actually pushes OK button, assume the user cancels&lt;BR /&gt;
boolFormCanceled = True&lt;BR /&gt;
myForm.show&lt;BR /&gt;
if boolFormCanceled = true then Exit Sub&lt;BR /&gt;
&lt;BR /&gt;
In your userform, if you have an OK button that the user clicks to keep&lt;BR /&gt;
going (assuming it's named btnOK), put the following:&lt;BR /&gt;
&lt;BR /&gt;
Private Sub btnOK_Click()&lt;BR /&gt;
    boolFormCanceled = False&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
This way, the only way the user can keep the program going is to use the OK&lt;BR /&gt;
button.&lt;BR /&gt;
&lt;BR /&gt;
Good luck</description>
      <pubDate>Tue, 26 Nov 2002 14:04:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/exiting-a-macro-while-running/m-p/299769#M68093</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-11-26T14:04:53Z</dc:date>
    </item>
  </channel>
</rss>

