Excel Automation

D

Duc Le

Hi,

I have a question/advice.

I can create an embedded Excel object in my MFC app
in two ways.

Way 1:
CLSID clsid;
::CLSIDFromProgID(L"Excel.sheet",&clsid);
pItem->CreateNewItem(clsid);
LPDISPATCH lpDisp = pItem->GetIDispatch();
_Application app;
app.AttachDispatch(lpDisp);


Way 2:
pItem = new CEmdatCntrItem(pDoc);
pItem->CreateFromFile("k:sample.xlt");
pItem->DoVerb(OLEIVERB_SHOW, this);
LPDISPATCH lpDisp = pItem->GetIDispatch();
ASSERT(lpDisp);
_Worksheet ss;
ss.AttachDispatch(lpDisp);
_Application app = ss.GetApplication();


I am using automation with in-place activation/editing.
The documentations I have read imply that to do
in-place activation/editing, I would need
COleDocObjectItem to contain the dispatch pointer. Way 2
does this. How do I get Way 1 to go through the
COleDocObjectItem????

It also seems with Way 2, I can only have one instance
of the application running at one time. Is the server
application somehow tied to the running instance???

Thanks.

Duc Le
(e-mail address removed)
 

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