MFC Excel Automation problem

D

Donkeylung

I have a basic MFC Excel Automation Issue. I create the Dispatch, but
Excel only "blinks" open, but it does not remain that way.

I get the excel object of an MFC Type Library.

I have

if(!AfxOleInit()) // Your addition starts here
{
AfxMessageBox("Could not initialize COM dll");
return FALSE;
}

in the InitInstance() function.

and

CApplication1 oExcel;//Generated _Application object

if(!oExcel.CreateDispatch("Excel.Application"))
{
AfxMessageBox("Could not start Excel.");
}
oExcel.put_Visible(TRUE);
oExcel.ReleaseDispatch();

in the event handler.

When I did the same thing in Word (with its own _Application object and
"Word.Application" in CreateDispatch) , it opens with no problems, but
the Excel will not stay open.

Any Suggestions? This seems so basic. What am I doing wrong.

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