AnsweredAssumed Answered

vrf ActiveX closing down excel properly

Question asked by VRFuser on Nov 25, 1999
Hi Brian.

[closing Excel programmatically]
> Any thoughts???

We had mentioned using the TerminateProcess API call previously, though
there is a catch.

As far as terminating Excel goes, did you try explicitly deleting the object
variable? I can't try Excel (not loaded... will try later at home) but all
the automation servers I have will AddRef and Release properly.

Alternatively, you could launch Excel first and use GetObject rather than
CreateObject. This in fact may be the problem. Maybe CreateObject actually
winds up calling AddRef twice, where Delete Variable would call Release only
once.

As far as TerminateProcess goes, it takes a process handle, which must be
obtained with OpenProcess for which one needs a Process ID. The target
process must also be opened with PROCESS_TERMINATE access which might be a
problem for some accounts (I don't know that it would be actually ... never
done it).

The real problem is getting a process ID. It's not really a big deal for
Windows 9x but it's pretty wild for Windows NT. Fortunately the code is
already in the SDK so it's pretty painless to assemble a dll that would
return a list of running processes & their IDs. Or to simply accept a string
such as "EXCEL.EXE" and terminate it.

It's worth mentioning that this should be a last-resort scenario. Calling
TerminateProcess, like TerminateThread, is not a nice thing to do.

All that said, open a command prompt and type kill /?. It's quite easily
done with an ExecuteProgram object.

Shawn Fessenden
Mgr., Technical Support
Oswego Software, Inc.
mailto:shawn@oswegosw.com
http://www.oswegosw.com


-----Original Message-----
From: owner-vrf@hplvlrx.lvld.hp.com
[mailto:owner-vrf@hplvlrx.lvld.hp.com]On Behalf Of Brian Kocinski
Sent: Tuesday, November 09, 1999 9:40 AM
To: vrf@lvld.hp.com
Subject: vrf ActiveX closing down excel properly


About a week ago this message was posted on the VRF, and what caught my
interest is the last sentence, "If it remains a serious problem maybe you
can AX into the task manager to kill programmatically".  Has anyone done
this or have an idea of a way to Ax into task manager to kill processes???
With NT4 and VEE 5.01, I Ax to Excel and then try to close the process.  As
we all know the instance of excel.exe isn't deleted until VEE is closed.
This poses many issues as we all know, but mainly NT won't allow a user to
open any Excel files until you either delete the excel.exe process using
task manager or close VEE.  So while the test program is running a user
can't open Excel files and work on them until either of the above two steps
are accomplished.  So if closing the process using task manager could be
hardcoded in VEE after closing Excel this would take care of the problem.
Sincerely,
Brian C. Kocinski
Test Engineer
Alto-Shaam, Inc.
Direct: (262) 253-6472
Fax    : (262) 251-1565
briank@alto-shaam.com

-----Original Message-----
From:     owner-vrf@hplvlrx.lvld.hp.com <mailto:owner-vrf@hplvlrx.lvld.hp.com>
[mailto:owner-vrf@hplvlrx.lvld.hp.com]
<mailto:[mailto:owner-vrf@hplvlrx.lvld.hp.com]>  On Behalf Of Andy Street
Sent:     Monday, November 01, 1999 6:22 AM
To:     Niki Evans
Cc:     HP VEE discussion group
Subject:     Re: vrf ActiveX closing down excel properly

Hi Niki,

It is a conflict between VEE 5.x and Excel - something to do with
maintaining variables for the line probes etc means keeping Excel in memory.
I think there is some mention of the issue in "Advanced Programming with
VEE" manual.  I have exactly the same problems with MATLAB in terms of it
not being totally killed when I close it.  I think that the ver 6 may
resolve this.  It is strange how you get problems kicking Excel off again as
I thought VEE would totally kill the app if it starts off a new instance of
it.  (It kills it if you close VEE).
If it remains a serious problem maybe you can AX into the task manager to
kill programmatically.
andy
----------------------
Andy Street
Tel: +44-1-865-273178

---------------------------------------------------------------------
This is the "vrf" maillist, managed by Majordomo.  To send messages to this
maillist, just email to "vrf@lvld.hp.com <mailto:vrf@lvld.hp.com> ".
Subscriptions and unsubscriptions are done through the address
"vrf-request@lvld.hp.com <mailto:vrf-request@lvld.hp.com> ".  If you need
details, just send a message containing the text "help" to
"vrf-request@lvld.hp.com <mailto:vrf-request@lvld.hp.com> ".
---------------------------------------------------------------------
---------------------------------------------------------------------
This is the "vrf" maillist, managed by Majordomo.  To send messages to
this maillist, just email to "vrf@lvld.hp.com".  Subscriptions and
unsubscriptions are done through the address "vrf-request@lvld.hp.com".
If you need details, just send a message containing the text "help"
to "vrf-request@lvld.hp.com".
---------------------------------------------------------------------

---------------------------------------------------------------------
This is the "vrf" maillist, managed by Majordomo.  To send messages to
this maillist, just email to "vrf@lvld.hp.com".  Subscriptions and
unsubscriptions are done through the address "vrf-request@lvld.hp.com".
If you need details, just send a message containing the text "help"
to "vrf-request@lvld.hp.com".
---------------------------------------------------------------------

Outcomes