View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jialiang Ge [MSFT] Jialiang Ge [MSFT] is offline
external usenet poster
 
Posts: 118
Default More about trying to automation multiple Excel instances

Good morning, Sergei. Thank you for this great summary. According to the
test results, the only solution to automate multiple Excel instances seems
to be "file moniker", which was also mentioned in the "method 1" of my
initial reply, and was demonstrated in the KB article: How to get IDispatch
of an Excel or Word document from an OCX.
http://support.microsoft.com/kb/q190985/

Sergei, if you want to dig out the reason for the failure of "item moniker"
("!{00024500-0000-0000-C000-000000000046}".), I'm very willing to help. In
fact, I'm also interested in the product team's consideration behind this
design. My researches so far are at the bottom of this message. Though the
reason has not been found out, I am going to discuss it with the Excel
designers directly.

--------------------------------------------------
My researches so far:

I start two instances of Excel, open two workbooks (Book1.xls, Book2.xls)
respectively. In order to see the current ROT status visually, I use the
tool "ROT Viewer" shipped with VC6. ROT Viewer lists the following monikers
related to Excel:

{!00024500-0000-0000-C000-000000000046}
{!00024500-0000-0000-C000-000000000046}
D:\test\book1.xls
D:\test\book2.xls

where the first two are item monikers and the rest are file monikers. From
ROT Viewer, I also see the item monikers have the same properties, e.g.
Hash Value. To verify whether they indeed refer to the same instance, I
wrote a small program to enumrunnings, cast them to Excel.Application, and
as you found out, the automation code run on these Excel.Application
objects only happens to the first instance of Excel. That's to say, the two
instances refer to the same instance of Excel.

I'm holding further discussions with my colleagues, and I promise to be
back soon.

Regards,
Jialiang Ge , remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================