Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 28th, 2006, 07:40 PM
Authorized User
 
Join Date: Jul 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default end process in task mgr

 I have a .mdb that creates a excel spreadsheet. The .mdb saves the spreadsheet and releases excel from memory.

appExcel.close 'close excel application
set appExcel to nothing 'releasing Excel application
set bks to nothing 'releasing the workbook
set wks to nothing 'releasing the worksheet

However, if you open the task mgr after running the script, I still see Excel.exe under the process tab. I have to manually select excel.exe in the task mgr and click end process.

If I dont do this and try tu run the script (in access) again, it error out. Is there another call to end this process programatically from access? Is it an API call?

 
Old September 29th, 2006, 06:56 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You posted this in two different forums that I have found so far. Here is an answer: Run this before you run your Excel code to make sure there are no processes running.

Dim sComputer

sComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel = impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("SELECT * FROM Win32_Process")
For Each objProcess in colProcesses
    If objProcess.Name = "EXCEL.EXE" Then
           errReturnCode = objProcess.Terminate()
       End If
Next


mmcdonal
 
Old September 29th, 2006, 10:03 AM
Authorized User
 
Join Date: Jul 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

mmcdonal,

This worked perfect - it errored out the first time I stepped thru but I changed the strComputer to sComputer and it worked great. I opened the task mgr with Excel.exe process running then stepped thru the code you provided - the process dissappear in the task mgr. I liked the fact that there is not a lot of code (less noise is better). Anyway, I really appreciate the help on this...take care!

Brent

 
Old September 29th, 2006, 10:14 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry about the mix up with the variable name. Glad to have helped.

mmcdonal
 
Old August 13th, 2007, 04:30 PM
Registered User
 
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Theres a huge problem with that solution. This will kill ALL excel processes. Including any that you may be manually working on. Had that happen to me. I forgot I had that code in one of my automated programs and I lost my excel file that I was working on.






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to hide a process in task manager ri_shu C++ Programming 3 October 25th, 2007 10:22 PM
Oracle back-end MS-Access 2003 client front-end Corey Access 2 February 16th, 2007 08:31 AM
end process in task mgr bab02 Access 2 September 29th, 2006 06:46 AM
how to hide a process in task manager ri_shu Visual C++ 0 April 5th, 2006 07:33 AM
how to hide the process from the task-manager ri_shu VB How-To 0 April 5th, 2006 07:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.