How to find and reference multiple Instances of Excel
This has been discussed several times in this ng, but I
cannot find a solution (apologies if I've have missed it).
John (jaf) posted some code he
http://tinyurl.com/6e78t
Arriving at his "MyGetXl()" looked promising, but on
further testing:
Set oxl = GetObject(MyFileName)
only works if MyFileName is an unsaved file named Bookx
(in first the window of the given instance),
or,
it could be a saved file if in the Instance of XL that is
running the code.
One could achieve as much, without any API's, with
something like this:
For i = 1 to say 20
Set oxl = GetObject("Book" & i)
' test for this and that, then reference oxl.Parent
Next
So, if every instance had an unsaved file "Bookx" it would
be very easy. An addin could Add a new wb and hide it on
startup - doable but not nice.
http://support.microsoft.com/?kbid=238975
The "Note" in this article in part reads:
....you cannot attach to any instance except for the
first. However, because Office applications also
register their documents in the ROT, you can successfully
attach to other instances by iterating the ROT looking for
a specific document, attaching to this document, and then
getting the Application object from this document.
(links to a C++ method which I cannot follow)
If a document is found, say with John's method or
enumerating windows XLMAIN XLDESK EXCEL7, does anyone
have an idea how to attach to this document, with which to
reference it's parent instance?
TIA,
Sandy
savituk yahoo co uk