Call Excel from VC++ Win32 DLL

J

Julia

Hi

I am writing a VC++ Win32 DLL, and in one of the functions that I'm
exporting I need to do the equivalent of the following VB code:

Dim oExcelApp as Object
‘ oExcelApp gets set to Excel.Application in call to third party DLL
oExcelApp.ActiveSheet.ChartObjects(1).CopyPicture

In my VC++ project oExcelApp is declared as follows:
IDispatch *pExcelApp;

How can I implement the functionality in the VB code above in VC++?
I've searched various news groups and MSDN and it seems that I have
two choices:

1) use the #import directive (excel9.olb)
2) work with such APIs as CoCreateInstance(), and COM interfaces such
as IDispatch

I try the #import but I get loads of compilation errors, for example:
error C2504: '_IMsoDispObj' : base class undefined

With point 2, surely I still have to include some files to include
references to Excel? Also I'm not sure how to even go about this.

Please can someone give me step-by-step instructions on how to call
Excel from VC++.

Many thanks.
Julia.
 

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