Word/Excel Automation, c++, multiple instance problem

N

Nicolas Stohler

I use Word/Excel automation in a MFC/C++ project to create reports from
xml data files. Some reports have diagrams in them, so we linked Excel
charts into word files. Once the Xml Data is imported into Excel and
Word, we open the word file and Update() the LinkFormats, then call
BreakLink() on them to convert the linked Excel charts into
word-grafics. this whole process works most of the time

I've detected that the Update() call to Words LinkFormats fails when
there's already another Excel instance running on the system AND any
modal dialog box 'blocks' that Excel instance (eg. options dialog, cell
properties dialog, ...). If this is the case, word cannot call
update()/breakLinks() and the report does not get generated.

1. I create the excel application object like this:
Excel11::_AplicationPtr p;
p.CreateInstance("Excel.Application");
is there an alternative to do this?
We did have code to check if there's already an instance of excel open
and then told the user to shut it down, but I didn't like that
approach. I think it's better to start my own instance of excel, work
with it, then shut it down when the report is done.

2. or is there a way to find out if any running instance of excel/word
is currently being blocked by a modal dialog box?


thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top