aquila98
asked on
How to use Excel COM interface in VC ???
Hi,
I have been able to get (using OLEView) the stub files for the COM
interface to Excel (XL5EN32.c and XL5EN32.h/idl)... So far so good :)
But which of the hundreds of CLSID do I use to instanciate an object?
And which objects to instanciate???
Here's what I want to do:
Open an XL sheet in a C++ application (MFC);
Read some cells;
Write to some cells;
save the sheet.
All this is simple in VB once you get a starting object...
But how to do it in VC??? Any hints? Any doc anywhere online?
I guess this code is close:
HRESULT hr;
hr = CoInitialize(0);
Application *w; // is this the right starting object???
hr = CoCreateInstance( CLSID__ExcelApplication, NULL,
CLSCTX_INPROC_SERVER, DIID_Application, (void**) &w);
is it the right CLSID and IDD???
any hints on how to use this interface in VC will be welcomed :)
Thanks
I have been able to get (using OLEView) the stub files for the COM
interface to Excel (XL5EN32.c and XL5EN32.h/idl)... So far so good :)
But which of the hundreds of CLSID do I use to instanciate an object?
And which objects to instanciate???
Here's what I want to do:
Open an XL sheet in a C++ application (MFC);
Read some cells;
Write to some cells;
save the sheet.
All this is simple in VB once you get a starting object...
But how to do it in VC??? Any hints? Any doc anywhere online?
I guess this code is close:
HRESULT hr;
hr = CoInitialize(0);
Application *w; // is this the right starting object???
hr = CoCreateInstance( CLSID__ExcelApplication, NULL,
CLSCTX_INPROC_SERVER, DIID_Application, (void**) &w);
is it the right CLSID and IDD???
any hints on how to use this interface in VC will be welcomed :)
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Very nice! Thanks ;-)
That's what was missing I guess... The #inport :)
Except, I got these errors for the excel9 file:
excel9.tlh(10494) : warning C4003: not enough actual parameters for macro 'DialogBoxA'
excel9.tlh(10494) : error C2059: syntax error : ',
....
It's complaining about this DialogBoxA is there
any more rename I should do?
I am close to a solution, thanks for your help
That's what was missing I guess... The #inport :)
Except, I got these errors for the excel9 file:
excel9.tlh(10494) : warning C4003: not enough actual parameters for macro 'DialogBoxA'
excel9.tlh(10494) : error C2059: syntax error : ',
....
It's complaining about this DialogBoxA is there
any more rename I should do?
I am close to a solution, thanks for your help
ASKER
Silly me!
I remembered the rename MUST be on the same line
as the import for it to work ;-)
Thanks for your help
I remembered the rename MUST be on the same line
as the import for it to work ;-)
Thanks for your help
Am I missing something?