Can you share code that enumerates multiple Excel windows.
Peter T wrote:
As already suggested, where the filename is known use GetObject to
23-Jul-08
As already suggested, where the filename is known use GetObject to referenc
the workbook then attach to the parent application
For situations where there is no known loaded wb, Jialiang Ge appears t
have demonstrated how to find multiple instances with .ne
For VBA, I have two methods, briefly
The first enumerates Excel windows, then workbook windows to find the fil
name of a loaded wb. Having got that try GetObject > parent. If that fails
eg no loaded workbooks at all or some other reason, use DDE (from a helpe
app) to add a new dummy hidden wb and try again
The other way is finding in the ROT (clever stuff, not mine!) There ar
dis/advantages with each. Via the ROT is faster but can't get be sure to ge
all instances, eg no loaded wb as can with DDE (usually!)
If anyone is interested I have a demo that implements both methods. Havin
got the ref's the withevents xlApp classes can track and record changes t
cells in all wb's in all instances, and one or two other things
Regards
Peter
pmbthornton gmail co
alread
open?
Previous Posts In This Thread:
GetObject when more than 1 Excel is running
From within VB.Net, if I want to access an instance of Excel that is already
running, I'd use something like
dim Exc as Excel.Applicatio
Exc = GetObject(, "Excel.Application"
However, suppose I have more than one instance of Excel open. Is there a
way to cycle through each open instance, and to pick a specific one to open
--
Ed
Re: GetObject when more than 1 Excel is running
Ed
Check out this page
http://support.microsoft.com/kb/28890
Here's the relevant part
You can attach to a specific instance if you know the name of an open
document in that instance. For example, if an instance of Excel is running
with an open workbook named Book2, the following code attaches successfully
to that instance even if it is not the earliest instance that was launched
Set xlApp = GetObject("Book2").Applicatio
Depending on what you're doing you might consider using CreateObject instead
and opening the file you are interested in. I think that's generally
considered a safer practice
hth
Dou
As already suggested, where the filename is known use GetObject to
As already suggested, where the filename is known use GetObject to referenc
the workbook then attach to the parent application
For situations where there is no known loaded wb, Jialiang Ge appears t
have demonstrated how to find multiple instances with .ne
For VBA, I have two methods, briefly
The first enumerates Excel windows, then workbook windows to find the fil
name of a loaded wb. Having got that try GetObject > parent. If that fails
eg no loaded workbooks at all or some other reason, use DDE (from a helpe
app) to add a new dummy hidden wb and try again
The other way is finding in the ROT (clever stuff, not mine!) There ar
dis/advantages with each. Via the ROT is faster but can't get be sure to ge
all instances, eg no loaded wb as can with DDE (usually!)
If anyone is interested I have a demo that implements both methods. Havin
got the ref's the withevents xlApp classes can track and record changes t
cells in all wb's in all instances, and one or two other things
Regards
Peter
pmbthornton gmail co
alread
open?
Submitted via EggHeadCafe - Software Developer Portal of Choice
Xcompress - IIS HTTP Compression
http://www.eggheadcafe.com/tutorial...c7-861a0909f404/xcompress--iis-http-comp.aspx