Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creating IOleObject for Excel Worksheet

62 views
Skip to first unread message

OBQuiet

unread,
Sep 26, 2008, 11:41:49 AM9/26/08
to
I am trying to embed an Excel sheet in an app using the DSOFramer
control. Unfortunately, opening by creating an instance of the
worksheet object, as DSOFramer does, uses any already opened instances
of Excel which causes problems when shutting down or if the opened
Excel instance is editing.

I've been trying to modify the code to open a new instance of Excel
and create a worksheet use for embedding but can't get it to work.
Basicly it is as follows:

Excel::_ApplicationPtr excelApp;
hr = excelApp.CreateInstance("Excel.Application");
if(SUCCEEDED(hr))
try{
Excel::WorkbooksPtr workBooks= excelApp->GetWorkbooks();
Excel::_WorkbookPtr book = workBooks->Add();
Excel::SheetsPtr sheets= book->GetWorksheets();
IDispatchPtr sheet = sheets->Add();
hr = sheet.QueryInterface(IID_IOleObject,ppole);
}catch(.........

The last call to QI returns E_NOINTERFACE.

I must be missing something or misunderstanding the Excel Object
model.

Is there a way to get the IOleObject I need to allow this to be
embedded from a specific instance of Excel?

TIA

Otis


Alexander Nickolov

unread,
Oct 30, 2008, 2:10:06 PM10/30/08
to
You are accessing the Excel Automation object hierarchy.
You can't get an OLE object from it..

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================

"OBQuiet" <obri...@my-dejanews.com> wrote in message
news:4141900c-0301-4ea0...@b1g2000hsg.googlegroups.com...

0 new messages