<?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: Closing a program that is open in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304792#M44232</link>
    <description>ok.. so now I'm down to this...&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt;CODE&lt;BR /&gt;
AppActivate "acad"&lt;BR /&gt;
SendKeys "%{F4}"&lt;BR /&gt;
&amp;gt;CODE&lt;BR /&gt;
I've tried Autodesk Architectural Desktop 3.3 and acad.exe  and on both I &lt;BR /&gt;
get a "type mismatch" on the AppActive line.&lt;BR /&gt;
&lt;BR /&gt;
Anyone help please&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"AlmightySR" &lt;ALMIGHTYSR&gt; wrote in message &lt;BR /&gt;
news:4824526@discussion.autodesk.com...&lt;BR /&gt;
&amp;gt;I was thinking about the ALT+F4 close command because that will prompt for &lt;BR /&gt;
&amp;gt;save|yes/no.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&amp;gt;CODE&lt;BR /&gt;
&amp;gt; AppActivate("ACAD.exe")&lt;BR /&gt;
&amp;gt; SendKeys "%{ }{ALT}{F4}", 0  'ALT, F4&lt;BR /&gt;
&amp;gt;&amp;gt;CODE&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; But this code I made is wrong and I think its in the send keys line.  My &lt;BR /&gt;
&amp;gt; Keys names are messed up.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; The command that is listed in the post, the "objProcess.Terminate" &lt;BR /&gt;
&amp;gt; command.. I think that will just end CAD with out prompting for save if I &lt;BR /&gt;
&amp;gt; understand it correctly.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; And I am getting a runtime error on it too, when I tried it out.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Any ideas on the send keys command OR the Terminate command?&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; &lt;GTVIC&gt; wrote in message news:4823878@discussion.autodesk.com...&lt;BR /&gt;
&amp;gt;&amp;gt; Are you sure this is a good idea. What if the dwg is not saved or a &lt;BR /&gt;
&amp;gt;&amp;gt; command is active? In those cases the application won't close.&lt;BR /&gt;
&amp;gt;&amp;gt;&lt;BR /&gt;
&amp;gt;&amp;gt; I couldn't find a Close method for the WsShell object:&lt;BR /&gt;
&amp;gt;&amp;gt;&lt;BR /&gt;
&amp;gt;&amp;gt; Microsoft link -&amp;gt; http://tinyurl.com/5e7gh&lt;BR /&gt;
&amp;gt;&amp;gt;&lt;BR /&gt;
&amp;gt;&amp;gt; Here is some code I found using Google: (link -&amp;gt; &lt;BR /&gt;
&amp;gt;&amp;gt; http://tinyurl.com/7dmnv)&lt;BR /&gt;
&amp;gt;&amp;gt;&lt;BR /&gt;
&amp;gt;&amp;gt; [code]&lt;BR /&gt;
&amp;gt;&amp;gt; Set colProcessList = objWMIService.ExecQuery ("SELECT * FROM &lt;BR /&gt;
&amp;gt;&amp;gt; Win32_Process WHERE Name = 'acad.exe'")&lt;BR /&gt;
&amp;gt;&amp;gt; For Each objProcess In colProcessList&lt;BR /&gt;
&amp;gt;&amp;gt;    objProcess.Terminate()&lt;BR /&gt;
&amp;gt;&amp;gt; Next&lt;BR /&gt;
&amp;gt;&amp;gt; [/code]&lt;/GTVIC&gt;&lt;/ALMIGHTYSR&gt;</description>
    <pubDate>Mon, 25 Apr 2005 12:59:07 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2005-04-25T12:59:07Z</dc:date>
    <item>
      <title>Closing a program that is open</title>
      <link>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304789#M44229</link>
      <description>If you havent read my last post I'm working on a program and part of what it &lt;BR /&gt;
does is opens and closes ACAD for the user.  I'm having trouble getting this &lt;BR /&gt;
VBS to close ALL instancess of CAD.  Would anyone have an ideas on how to do &lt;BR /&gt;
this?&lt;BR /&gt;
&lt;BR /&gt;
I thought it might be as simple as&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt;CODE&lt;BR /&gt;
Dim WshShell&lt;BR /&gt;
' Create a WSH Shell object.&lt;BR /&gt;
Set WshShell = _&lt;BR /&gt;
CreateObject("WScript.Shell")&lt;BR /&gt;
' Close AutoCAD application.&lt;BR /&gt;
WshShell.close _&lt;BR /&gt;
"""C:\Program Files\Autodesk Architectural Desktop 3\acad.exe""", _&lt;BR /&gt;
1, _&lt;BR /&gt;
True&lt;BR /&gt;
&amp;gt;CODE&lt;BR /&gt;
&lt;BR /&gt;
But i'm obviously wrong</description>
      <pubDate>Fri, 22 Apr 2005 19:01:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304789#M44229</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-04-22T19:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Closing a program that is open</title>
      <link>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304790#M44230</link>
      <description>Are you sure this is a good idea. What if the dwg is not saved or a command is active? In those cases the application won't close.&lt;BR /&gt;
&lt;BR /&gt;
I couldn't find a Close method for the WsShell object:&lt;BR /&gt;
&lt;BR /&gt;
Microsoft link -&amp;gt; http://tinyurl.com/5e7gh&lt;BR /&gt;
&lt;BR /&gt;
Here is some code I found using Google: (link -&amp;gt; http://tinyurl.com/7dmnv)&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
Set colProcessList = objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE Name = 'acad.exe'")&lt;BR /&gt;
For Each objProcess In colProcessList&lt;BR /&gt;
    objProcess.Terminate()&lt;BR /&gt;
Next&lt;BR /&gt;
[/code]</description>
      <pubDate>Fri, 22 Apr 2005 22:08:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304790#M44230</guid>
      <dc:creator>GTVic</dc:creator>
      <dc:date>2005-04-22T22:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: Closing a program that is open</title>
      <link>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304791#M44231</link>
      <description>I was thinking about the ALT+F4 close command because that will prompt for &lt;BR /&gt;
save|yes/no.&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt;CODE&lt;BR /&gt;
AppActivate("ACAD.exe")&lt;BR /&gt;
SendKeys "%{ }{ALT}{F4}", 0  'ALT, F4&lt;BR /&gt;
&amp;gt;CODE&lt;BR /&gt;
&lt;BR /&gt;
But this code I made is wrong and I think its in the send keys line.  My &lt;BR /&gt;
Keys names are messed up.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The command that is listed in the post, the "objProcess.Terminate" command.. &lt;BR /&gt;
I think that will just end CAD with out prompting for save if I understand &lt;BR /&gt;
it correctly.&lt;BR /&gt;
&lt;BR /&gt;
And I am getting a runtime error on it too, when I tried it out.&lt;BR /&gt;
&lt;BR /&gt;
Any ideas on the send keys command OR the Terminate command?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;GTVIC&gt; wrote in message news:4823878@discussion.autodesk.com...&lt;BR /&gt;
&amp;gt; Are you sure this is a good idea. What if the dwg is not saved or a &lt;BR /&gt;
&amp;gt; command is active? In those cases the application won't close.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; I couldn't find a Close method for the WsShell object:&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Microsoft link -&amp;gt; http://tinyurl.com/5e7gh&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Here is some code I found using Google: (link -&amp;gt; http://tinyurl.com/7dmnv)&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; [code]&lt;BR /&gt;
&amp;gt; Set colProcessList = objWMIService.ExecQuery ("SELECT * FROM Win32_Process &lt;BR /&gt;
&amp;gt; WHERE Name = 'acad.exe'")&lt;BR /&gt;
&amp;gt; For Each objProcess In colProcessList&lt;BR /&gt;
&amp;gt;    objProcess.Terminate()&lt;BR /&gt;
&amp;gt; Next&lt;BR /&gt;
&amp;gt; [/code]&lt;/GTVIC&gt;</description>
      <pubDate>Mon, 25 Apr 2005 11:04:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304791#M44231</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-04-25T11:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: Closing a program that is open</title>
      <link>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304792#M44232</link>
      <description>ok.. so now I'm down to this...&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt;CODE&lt;BR /&gt;
AppActivate "acad"&lt;BR /&gt;
SendKeys "%{F4}"&lt;BR /&gt;
&amp;gt;CODE&lt;BR /&gt;
I've tried Autodesk Architectural Desktop 3.3 and acad.exe  and on both I &lt;BR /&gt;
get a "type mismatch" on the AppActive line.&lt;BR /&gt;
&lt;BR /&gt;
Anyone help please&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"AlmightySR" &lt;ALMIGHTYSR&gt; wrote in message &lt;BR /&gt;
news:4824526@discussion.autodesk.com...&lt;BR /&gt;
&amp;gt;I was thinking about the ALT+F4 close command because that will prompt for &lt;BR /&gt;
&amp;gt;save|yes/no.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&amp;gt;CODE&lt;BR /&gt;
&amp;gt; AppActivate("ACAD.exe")&lt;BR /&gt;
&amp;gt; SendKeys "%{ }{ALT}{F4}", 0  'ALT, F4&lt;BR /&gt;
&amp;gt;&amp;gt;CODE&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; But this code I made is wrong and I think its in the send keys line.  My &lt;BR /&gt;
&amp;gt; Keys names are messed up.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; The command that is listed in the post, the "objProcess.Terminate" &lt;BR /&gt;
&amp;gt; command.. I think that will just end CAD with out prompting for save if I &lt;BR /&gt;
&amp;gt; understand it correctly.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; And I am getting a runtime error on it too, when I tried it out.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Any ideas on the send keys command OR the Terminate command?&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; &lt;GTVIC&gt; wrote in message news:4823878@discussion.autodesk.com...&lt;BR /&gt;
&amp;gt;&amp;gt; Are you sure this is a good idea. What if the dwg is not saved or a &lt;BR /&gt;
&amp;gt;&amp;gt; command is active? In those cases the application won't close.&lt;BR /&gt;
&amp;gt;&amp;gt;&lt;BR /&gt;
&amp;gt;&amp;gt; I couldn't find a Close method for the WsShell object:&lt;BR /&gt;
&amp;gt;&amp;gt;&lt;BR /&gt;
&amp;gt;&amp;gt; Microsoft link -&amp;gt; http://tinyurl.com/5e7gh&lt;BR /&gt;
&amp;gt;&amp;gt;&lt;BR /&gt;
&amp;gt;&amp;gt; Here is some code I found using Google: (link -&amp;gt; &lt;BR /&gt;
&amp;gt;&amp;gt; http://tinyurl.com/7dmnv)&lt;BR /&gt;
&amp;gt;&amp;gt;&lt;BR /&gt;
&amp;gt;&amp;gt; [code]&lt;BR /&gt;
&amp;gt;&amp;gt; Set colProcessList = objWMIService.ExecQuery ("SELECT * FROM &lt;BR /&gt;
&amp;gt;&amp;gt; Win32_Process WHERE Name = 'acad.exe'")&lt;BR /&gt;
&amp;gt;&amp;gt; For Each objProcess In colProcessList&lt;BR /&gt;
&amp;gt;&amp;gt;    objProcess.Terminate()&lt;BR /&gt;
&amp;gt;&amp;gt; Next&lt;BR /&gt;
&amp;gt;&amp;gt; [/code]&lt;/GTVIC&gt;&lt;/ALMIGHTYSR&gt;</description>
      <pubDate>Mon, 25 Apr 2005 12:59:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304792#M44232</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-04-25T12:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Closing a program that is open</title>
      <link>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304793#M44233</link>
      <description>Much the same advice as before - you probably don't really want to do this but here's a nice length of rope:&lt;BR /&gt;
&lt;BR /&gt;
   Dim Acad&lt;BR /&gt;
   &lt;BR /&gt;
   On Error Resume Next&lt;BR /&gt;
   Do&lt;BR /&gt;
      Set Acad = Nothing&lt;BR /&gt;
      Set Acad = GetObject(, "AutoCad.Application")&lt;BR /&gt;
      Acad.Quit&lt;BR /&gt;
   Loop Until Acad Is Nothing&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
And now for a question: Do you have access to any documentation?</description>
      <pubDate>Mon, 25 Apr 2005 13:07:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304793#M44233</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-04-25T13:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Closing a program that is open</title>
      <link>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304794#M44234</link>
      <description>documentation for?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;FANTUM&gt; wrote in message news:4824590@discussion.autodesk.com...&lt;BR /&gt;
&amp;gt; Much the same advice as before - you probably don't really want to do this &lt;BR /&gt;
&amp;gt; but here's a nice length of rope:&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;   Dim Acad&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;   On Error Resume Next&lt;BR /&gt;
&amp;gt;   Do&lt;BR /&gt;
&amp;gt;      Set Acad = Nothing&lt;BR /&gt;
&amp;gt;      Set Acad = GetObject(, "AutoCad.Application")&lt;BR /&gt;
&amp;gt;      Acad.Quit&lt;BR /&gt;
&amp;gt;   Loop Until Acad Is Nothing&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; And now for a question: Do you have access to any documentation?&lt;/FANTUM&gt;</description>
      <pubDate>Mon, 25 Apr 2005 14:20:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304794#M44234</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-04-25T14:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: Closing a program that is open</title>
      <link>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304795#M44235</link>
      <description>WSH?&lt;BR /&gt;
&lt;BR /&gt;
Acad VBA?&lt;BR /&gt;
&lt;BR /&gt;
VBS?</description>
      <pubDate>Mon, 25 Apr 2005 14:39:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304795#M44235</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-04-25T14:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Closing a program that is open</title>
      <link>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304796#M44236</link>
      <description>I donthave thoughs... I'm learning thru the internet and helpful groups like &lt;BR /&gt;
this.  This is actually the first program I have ever made... Dis-counting &lt;BR /&gt;
batch files.&lt;BR /&gt;
&lt;BR /&gt;
&lt;FANTUM&gt; wrote in message news:4824712@discussion.autodesk.com...&lt;BR /&gt;
&amp;gt; WSH?&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Acad VBA?&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; VBS?&lt;/FANTUM&gt;</description>
      <pubDate>Mon, 25 Apr 2005 15:29:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304796#M44236</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-04-25T15:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Closing a program that is open</title>
      <link>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304797#M44237</link>
      <description>WSH:&lt;BR /&gt;
&lt;&gt;&lt;BR /&gt;
&lt;BR /&gt;
Acad VBA:&lt;BR /&gt;
acad_aag.chm in the Help directory of a machine with Acad.&lt;BR /&gt;
&lt;BR /&gt;
VBS:&lt;BR /&gt;
&lt;&gt;&lt;/&gt;&lt;/&gt;</description>
      <pubDate>Mon, 25 Apr 2005 16:46:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304797#M44237</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-04-25T16:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Closing a program that is open</title>
      <link>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304798#M44238</link>
      <description>That command you sent me is working great!  thank you&lt;BR /&gt;
&lt;BR /&gt;
&lt;FANTUM&gt; wrote in message news:4824933@discussion.autodesk.com...&lt;BR /&gt;
&amp;gt; WSH:&lt;BR /&gt;
&amp;gt; &lt;&gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Acad VBA:&lt;BR /&gt;
&amp;gt; acad_aag.chm in the Help directory of a machine with Acad.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; VBS:&lt;BR /&gt;
&amp;gt; &lt;&gt;&lt;/&gt;&lt;/&gt;&lt;/FANTUM&gt;</description>
      <pubDate>Mon, 25 Apr 2005 18:00:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304798#M44238</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-04-25T18:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Closing a program that is open</title>
      <link>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304799#M44239</link>
      <description>I mean "code"&lt;BR /&gt;
"AlmightySR" &lt;ALMIGHTYSR&gt; wrote in message &lt;BR /&gt;
news:4825049@discussion.autodesk.com...&lt;BR /&gt;
&amp;gt; That command you sent me is working great!  thank you&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; &lt;FANTUM&gt; wrote in message news:4824933@discussion.autodesk.com...&lt;BR /&gt;
&amp;gt;&amp;gt; WSH:&lt;BR /&gt;
&amp;gt;&amp;gt; &lt;&gt;&lt;BR /&gt;
&amp;gt;&amp;gt;&lt;BR /&gt;
&amp;gt;&amp;gt; Acad VBA:&lt;BR /&gt;
&amp;gt;&amp;gt; acad_aag.chm in the Help directory of a machine with Acad.&lt;BR /&gt;
&amp;gt;&amp;gt;&lt;BR /&gt;
&amp;gt;&amp;gt; VBS:&lt;BR /&gt;
&amp;gt;&amp;gt; &lt;&gt;&lt;/&gt;&lt;/&gt;&lt;/FANTUM&gt;&lt;/ALMIGHTYSR&gt;</description>
      <pubDate>Mon, 25 Apr 2005 18:00:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/closing-a-program-that-is-open/m-p/1304799#M44239</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-04-25T18:00:48Z</dc:date>
    </item>
  </channel>
</rss>

