Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.vb.winapi,microsoft.public.win32.programmer.kernel
external usenet poster
 
Posts: 1
Default Visible Instances of an Application

"TCook" wrote in message
...
I am building something that needs to grab a certain instance of MS Excel.
Unfortunately, "GetObject" randomly chooses an instance and, therefore, is
not appropriate / robust enough by itself. In pseudo code, what I need is
below:

For each pProcess in Processes
If instr(pProcess.Name, "Excel") 0 And pProcess.Visible = True
Then
Set MyAppInstance = pProcess.Instance

Exit For
End If
Next pProcess


This isn't really a kernel issue but as you posted here, and as you seem to
be after a process list, CreateToolhelp32Snapshot(), Process32First(), and
Process32Next() will get that for you. You can check the docs for the
ProcessEntry32 structure to see if it contains the data that you need.

Just by the way, the main window for the version of Excel I have installed
here has a window class name of "XLMAIN". If the class name is constant
across versions you could use EnumWindows() to list the windows and
GetClassName() to filter out Excel's.

Regards,
Will


  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.vb.winapi,microsoft.public.win32.programmer.kernel
external usenet poster
 
Posts: 22
Default Visible Instances of an Application

Hey Will,

Thanks for the info. After obtaining the appropriate process, can I then
actually get the instance of the Excel app such that I can work with its
object model?

Regards,

Todd



"William DePalo [MVP VC++]" wrote in message
...
"TCook" wrote in message
...
I am building something that needs to grab a certain instance of MS
Excel. Unfortunately, "GetObject" randomly chooses an instance and,
therefore, is not appropriate / robust enough by itself. In pseudo code,
what I need is below:

For each pProcess in Processes
If instr(pProcess.Name, "Excel") 0 And pProcess.Visible = True
Then
Set MyAppInstance = pProcess.Instance

Exit For
End If
Next pProcess


This isn't really a kernel issue but as you posted here, and as you seem
to be after a process list, CreateToolhelp32Snapshot(), Process32First(),
and Process32Next() will get that for you. You can check the docs for the
ProcessEntry32 structure to see if it contains the data that you need.

Just by the way, the main window for the version of Excel I have installed
here has a window class name of "XLMAIN". If the class name is constant
across versions you could use EnumWindows() to list the windows and
GetClassName() to filter out Excel's.

Regards,
Will



  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.vb.winapi,microsoft.public.win32.programmer.kernel
external usenet poster
 
Posts: 284
Default Visible Instances of an Application

Todd,

The MS Word object has a 'Tasks' collection that will let you isolate
visible instances of active Windows. It might be worth the trouble to
create a hidden instance of Word and get the list.

Steve


"TCook" wrote in message
...
Hey Will,

Thanks for the info. After obtaining the appropriate process, can I then
actually get the instance of the Excel app such that I can work with its
object model?

Regards,

Todd



"William DePalo [MVP VC++]" wrote in message
...
"TCook" wrote in message
...
I am building something that needs to grab a certain instance of MS
Excel. Unfortunately, "GetObject" randomly chooses an instance and,
therefore, is not appropriate / robust enough by itself. In pseudo
code, what I need is below:

For each pProcess in Processes
If instr(pProcess.Name, "Excel") 0 And pProcess.Visible = True
Then
Set MyAppInstance = pProcess.Instance

Exit For
End If
Next pProcess


This isn't really a kernel issue but as you posted here, and as you seem
to be after a process list, CreateToolhelp32Snapshot(), Process32First(),
and Process32Next() will get that for you. You can check the docs for the
ProcessEntry32 structure to see if it contains the data that you need.

Just by the way, the main window for the version of Excel I have
installed here has a window class name of "XLMAIN". If the class name is
constant across versions you could use EnumWindows() to list the windows
and GetClassName() to filter out Excel's.

Regards,
Will





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
Application.Visible = False SimonB Setting up and Configuration of Excel 1 October 16th 06 09:51 PM
Application.Visible = False SimonB Excel Discussion (Misc queries) 1 October 15th 06 01:10 PM
Runnig Excel without visible application [email protected] Excel Programming 2 March 25th 05 08:48 PM
Application.visible help Glen Mettler[_4_] Excel Programming 0 February 16th 05 10:04 PM
Linked Excel Chart within hidden Word Application Visible Obi-Too Excel Programming 0 June 23rd 04 03:58 PM


All times are GMT +1. The time now is 09:36 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"