Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default VB/VBA to read Task Manager

I use Scheduled Tasks to open, update and close several workbooks each
day. Sometimes at the end of the day there will be an Excel instance
or two showing in the Processes tab of Task Manager. Is there a way I
can find out which workbook is associated with the open instance, or
get any information at all about this instance that might help me
discover which workbook may have caused the problem?

tod
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default VB/VBA to read Task Manager

Tod,

You can use the vbScript I've got between the lines below. It will find all
running processes named Excel.exe and send up a message box for each with
the exact date and time the process was created and the process ID for that
instance. With the start time, you should be able to figure out which
workbook spawned the instance of the application. If you want, you can
certainly place the code in a VBA module and place the results in different
cells (WScript.Echo won't work in VBA) but I'd probably just paste into
Notepad and save the text file with a vbs extension to run as a vbScript.

______________________________________

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'excel.exe'")

For Each objProcess in colProcessList
dtmStartTime = objProcess.CreationDate
strReturn = WMIDateStringToDate(dtmStartTime) & vbCrLf _
& " Excel instance with process ID " & objProcess.ProcessID & "
started."
Wscript.Echo strReturn
Next

Function WMIDateStringToDate(dtmStart)
WMIDateStringToDate = CDate(Mid(dtmStart, 5, 2) & "/" & _
Mid(dtmStart, 7, 2) & "/" & Left(dtmStart, 4) _
& " " & Mid (dtmStart, 9, 2) & ":" & _
Mid(dtmStart, 11, 2) & ":" & Mid(dtmStart, _
13, 2))
End Function

______________________________________

Steve



"todtown" wrote in message
...
I use Scheduled Tasks to open, update and close several workbooks each
day. Sometimes at the end of the day there will be an Excel instance
or two showing in the Processes tab of Task Manager. Is there a way I
can find out which workbook is associated with the open instance, or
get any information at all about this instance that might help me
discover which workbook may have caused the problem?

tod



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default VB/VBA to read Task Manager

Not sure now where you can get it from, but there is a .dll file, written by
Edanmo Morgillo, tskschd.dll, that makes it easy to deal with the Windows
task scheduler in any way you want.
Do a Google for it or otherwise ask in
microsoft.public.vb.general.discussion

RBS


"todtown" wrote in message
...
I use Scheduled Tasks to open, update and close several workbooks each
day. Sometimes at the end of the day there will be an Excel instance
or two showing in the Processes tab of Task Manager. Is there a way I
can find out which workbook is associated with the open instance, or
get any information at all about this instance that might help me
discover which workbook may have caused the problem?

tod


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default VB/VBA to read Task Manager

In case you didn't catch it, the newsgroup post above got very slightly
broken. In the segment,

strReturn = WMIDateStringToDate(dtmStartTime) & vbCrLf _
& " Excel instance with process ID " & objProcess.ProcessID & "
started."

The third line
started."
should be at the end of the line above it........Steve



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB/VBA to read Task Manager todtown Excel Programming 0 December 26th 07 10:58 PM
Exel.Exe lingering in Task Manager Intui_Sol Excel Programming 2 September 25th 06 06:03 PM
excel.exe is not terminating from task manager Inthi Excel Programming 0 November 28th 05 01:39 PM
Task Manager and Excel 2003 Mike Excel Discussion (Misc queries) 1 April 20th 05 10:40 PM
EXCEL keeps running in task manager Sam Excel Programming 4 January 22nd 04 11:17 AM


All times are GMT +1. The time now is 03:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"