Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Determining All Instances of Excel

Hello,

I'm interested in determining all instances of Excel currently open on
my PC. I would then like to be able to loop through all of these
instances of Excel, and determine the Workbooks that are open in each
instance of Excel.

I understand that I can use something like the following code:

Dim myWB As Workbook
For Each myWB In Workbooks
MsgBox "Workbook: " & myWB.Name
Next myWB

to find all the workbooks in the current Excel Instance...but what
about all Excel Instances that are running on my PC.

Is there an easy way to do this?

Thanks
Sam Adams

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Determining All Instances of Excel

Hi Sam,

Is there an easy way to do this?


No, or rather putting something together to do that wasn't easy for me! The
problem is GetObject will return the first instance it finds. I gather with
C++ there's a method to return the 'Running Object Table' but I don't know
how to do that in VBA.

If this really important for you I can send you a workbook (code) that does
the following:

- Enumerate windows to find running Excel instances

- Also Enumerate windows to compile a list of all window captions named
BookX, (there will never be a duplicate unsaved BookX open), identify and
relate at least one BookX in each instance.

- If an instance doesn't contain an unsaved BookX use DDE (with Word) to
insert a new workbook and hide it for future use (don't know how to avoid
temporarily bringing the window to front to do that).

- Use GetObject to get one BookX from each instance or rather its parent
application.

Having got an array of WithEvents of each application gives pretty much the
same control over each as the instance containing the code. For my purposes
traps & stores changes to cells in all wb's in all instances, also a few
other things.

This is not trivial nor 100% reliable (though normally works). So as I
mentioned, unless you need this and you are relatively familiar with VBA I
wouldn't recommend it!

Regards,
Peter T
pmbthornton gmail com







wrote in message
ups.com...
Hello,

I'm interested in determining all instances of Excel currently open on
my PC. I would then like to be able to loop through all of these
instances of Excel, and determine the Workbooks that are open in each
instance of Excel.

I understand that I can use something like the following code:

Dim myWB As Workbook
For Each myWB In Workbooks
MsgBox "Workbook: " & myWB.Name
Next myWB

to find all the workbooks in the current Excel Instance...but what
about all Excel Instances that are running on my PC.

Is there an easy way to do this?

Thanks
Sam Adams



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
Create list of unique instances from list of multiple Instances Dishon Excel Worksheet Functions 0 March 3rd 08 10:46 AM
Determining how excel was started Gilgamesh[_3_] Excel Programming 3 September 23rd 05 01:26 PM
Determining Excel Version dstiefe Excel Programming 2 August 16th 05 03:13 PM
Excel VBA - determining range donfon13 Excel Programming 3 June 23rd 04 09:46 PM
Is there an easy way to replace list A instances with list B instances (sorted lists). kkip Excel Programming 3 December 31st 03 01:50 PM


All times are GMT +1. The time now is 09:25 PM.

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

About Us

"It's about Microsoft Excel"