The Code Cage - Microsoft Office help Free Microsoft Office Help for all Applications!  

To stop seeing these ads and get other benefits check This page!

Go Back   The Code Cage Forums > Newsgroups - Microsoft Topics > Newsgroup - Excel Forum > Excel VBA Programming
  Microsoft Office Chat Online now!


Excel VBA Programming Post questions in this forum if they are related to using Microsoft Excel VBA Programming, Macro's etc.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 21st January 2010, 07:58 PM
Obaid Ullah
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Chats:
Default enumerates Excel windows

------ Register to get rid of these "In Post" ads! ------


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 reference
the workbook then attach to the parent application.

For situations where there is no known loaded wb, Jialiang Ge appears to
have demonstrated how to find multiple instances with .net

For VBA, I have two methods, briefly:

The first enumerates Excel windows, then workbook windows to find the file
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 helper
app) to add a new dummy hidden wb and try again.

The other way is finding in the ROT (clever stuff, not mine!) There are
dis/advantages with each. Via the ROT is faster but can't get be sure to get
all instances, eg no loaded wb as can with DDE (usually!).

If anyone is interested I have a demo that implements both methods. Having
got the ref's the withevents xlApp classes can track and record changes to
cells in all wb's in all instances, and one or two other things.

Regards,
Peter T
pmbthornton gmail com



"Ed White" <ewhite@newsgroups.nospam> wrote in message
news:9985D161-FBD3-4E1B-8374-3CFC48C07E76@microsoft.com...
already
open?

Previous Posts In This Thread:

On Tuesday, July 22, 2008 6:41 PM
ewhit wrote:

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.Application
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

On Tuesday, July 22, 2008 10:49 PM
Doug Glancy wrote:

Re: GetObject when more than 1 Excel is running
Ed,

Check out this page:
http://support.microsoft.com/kb/288902

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").Application

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,

Doug

"Ed White" <ewhite@newsgroups.nospam> wrote in message
news:9985D161-FBD3-4E1B-8374-3CFC48C07E76@microsoft.com...

On Wednesday, July 23, 2008 8:35 AM
Peter T wrote:

As already suggested, where the filename is known use GetObject to
As already suggested, where the filename is known use GetObject to reference
the workbook then attach to the parent application.

For situations where there is no known loaded wb, Jialiang Ge appears to
have demonstrated how to find multiple instances with .net

For VBA, I have two methods, briefly:

The first enumerates Excel windows, then workbook windows to find the file
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 helper
app) to add a new dummy hidden wb and try again.
'Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/excel-vba-programming/172241-enumerates-excel-windows.html#post619604

The other way is finding in the ROT (clever stuff, not mine!) There are
dis/advantages with each. Via the ROT is faster but can't get be sure to get
all instances, eg no loaded wb as can with DDE (usually!).

If anyone is interested I have a demo that implements both methods. Having
got the ref's the withevents xlApp classes can track and record changes to
cells in all wb's in all instances, and one or two other things.

Regards,
Peter T
pmbthornton gmail com



"Ed White" <ewhite@newsgroups.nospam> wrote in message
news:9985D161-FBD3-4E1B-8374-3CFC48C07E76@microsoft.com...
already
open?


Submitted via EggHeadCafe - Software Developer Portal of Choice
Xcompress - IIS HTTP Compression
http://www.eggheadcafe.com/tutorials...http-comp.aspx
Reply to this post


Did you find this post helpful? Yes | No

The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
Reply

Bookmarks

Tags
enumerates, excel, windows


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Forum Jump

The Code Cage Affilliates


To stop seeing these ads and get other benefits check This page!



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


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2
No part of this board may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application the represent