Closing a program that is open

Closing a program that is open

Anonymous
Not applicable
659 Views
10 Replies
Message 1 of 11

Closing a program that is open

Anonymous
Not applicable
If you havent read my last post I'm working on a program and part of what it
does is opens and closes ACAD for the user. I'm having trouble getting this
VBS to close ALL instancess of CAD. Would anyone have an ideas on how to do
this?

I thought it might be as simple as

>CODE
Dim WshShell
' Create a WSH Shell object.
Set WshShell = _
CreateObject("WScript.Shell")
' Close AutoCAD application.
WshShell.close _
"""C:\Program Files\Autodesk Architectural Desktop 3\acad.exe""", _
1, _
True
>CODE

But i'm obviously wrong
0 Likes
660 Views
10 Replies
Replies (10)
Message 2 of 11

GTVic
Advisor
Advisor
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.

I couldn't find a Close method for the WsShell object:

Microsoft link -> http://tinyurl.com/5e7gh

Here is some code I found using Google: (link -> http://tinyurl.com/7dmnv)

[code]
Set colProcessList = objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE Name = 'acad.exe'")
For Each objProcess In colProcessList
objProcess.Terminate()
Next
[/code]
0 Likes
Message 3 of 11

Anonymous
Not applicable
I was thinking about the ALT+F4 close command because that will prompt for
save|yes/no.

>CODE
AppActivate("ACAD.exe")
SendKeys "%{ }{ALT}{F4}", 0 'ALT, F4
>CODE

But this code I made is wrong and I think its in the send keys line. My
Keys names are messed up.


The command that is listed in the post, the "objProcess.Terminate" command..
I think that will just end CAD with out prompting for save if I understand
it correctly.

And I am getting a runtime error on it too, when I tried it out.

Any ideas on the send keys command OR the Terminate command?


wrote in message news:4823878@discussion.autodesk.com...
> 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.
>
> I couldn't find a Close method for the WsShell object:
>
> Microsoft link -> http://tinyurl.com/5e7gh
>
> Here is some code I found using Google: (link -> http://tinyurl.com/7dmnv)
>
> [code]
> Set colProcessList = objWMIService.ExecQuery ("SELECT * FROM Win32_Process
> WHERE Name = 'acad.exe'")
> For Each objProcess In colProcessList
> objProcess.Terminate()
> Next
> [/code]
0 Likes
Message 4 of 11

Anonymous
Not applicable
ok.. so now I'm down to this...

>CODE
AppActivate "acad"
SendKeys "%{F4}"
>CODE
I've tried Autodesk Architectural Desktop 3.3 and acad.exe and on both I
get a "type mismatch" on the AppActive line.

Anyone help please



"AlmightySR" wrote in message
news:4824526@discussion.autodesk.com...
>I was thinking about the ALT+F4 close command because that will prompt for
>save|yes/no.
>
>>CODE
> AppActivate("ACAD.exe")
> SendKeys "%{ }{ALT}{F4}", 0 'ALT, F4
>>CODE
>
> But this code I made is wrong and I think its in the send keys line. My
> Keys names are messed up.
>
>
> The command that is listed in the post, the "objProcess.Terminate"
> command.. I think that will just end CAD with out prompting for save if I
> understand it correctly.
>
> And I am getting a runtime error on it too, when I tried it out.
>
> Any ideas on the send keys command OR the Terminate command?
>
>
> wrote in message news:4823878@discussion.autodesk.com...
>> 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.
>>
>> I couldn't find a Close method for the WsShell object:
>>
>> Microsoft link -> http://tinyurl.com/5e7gh
>>
>> Here is some code I found using Google: (link ->
>> http://tinyurl.com/7dmnv)
>>
>> [code]
>> Set colProcessList = objWMIService.ExecQuery ("SELECT * FROM
>> Win32_Process WHERE Name = 'acad.exe'")
>> For Each objProcess In colProcessList
>> objProcess.Terminate()
>> Next
>> [/code]
0 Likes
Message 5 of 11

Anonymous
Not applicable
Much the same advice as before - you probably don't really want to do this but here's a nice length of rope:

Dim Acad

On Error Resume Next
Do
Set Acad = Nothing
Set Acad = GetObject(, "AutoCad.Application")
Acad.Quit
Loop Until Acad Is Nothing


And now for a question: Do you have access to any documentation?
0 Likes
Message 6 of 11

Anonymous
Not applicable
documentation for?


wrote in message news:4824590@discussion.autodesk.com...
> Much the same advice as before - you probably don't really want to do this
> but here's a nice length of rope:
>
> Dim Acad
>
> On Error Resume Next
> Do
> Set Acad = Nothing
> Set Acad = GetObject(, "AutoCad.Application")
> Acad.Quit
> Loop Until Acad Is Nothing
>
>
> And now for a question: Do you have access to any documentation?
0 Likes
Message 7 of 11

Anonymous
Not applicable
WSH?

Acad VBA?

VBS?
0 Likes
Message 8 of 11

Anonymous
Not applicable
I donthave thoughs... I'm learning thru the internet and helpful groups like
this. This is actually the first program I have ever made... Dis-counting
batch files.

wrote in message news:4824712@discussion.autodesk.com...
> WSH?
>
> Acad VBA?
>
> VBS?
0 Likes
Message 9 of 11

Anonymous
Not applicable
WSH:
<>

Acad VBA:
acad_aag.chm in the Help directory of a machine with Acad.

VBS:
<>
0 Likes
Message 10 of 11

Anonymous
Not applicable
That command you sent me is working great! thank you

wrote in message news:4824933@discussion.autodesk.com...
> WSH:
> <>
>
> Acad VBA:
> acad_aag.chm in the Help directory of a machine with Acad.
>
> VBS:
> <>
0 Likes
Message 11 of 11

Anonymous
Not applicable
I mean "code"
"AlmightySR" wrote in message
news:4825049@discussion.autodesk.com...
> That command you sent me is working great! thank you
>
> wrote in message news:4824933@discussion.autodesk.com...
>> WSH:
>> <>
>>
>> Acad VBA:
>> acad_aag.chm in the Help directory of a machine with Acad.
>>
>> VBS:
>> <>
0 Likes