Programmatic Merging of two Excel Workbooks

V

Viraj

Hello All,

I am trying to Merge two Excel Worksheets programatically using VC++. The
steps involved in this are:
1 Get class id of the required class "Excel.Allpication".
2 Using “CoCreateInstance†create an instance of this class. This also
returns a pointer to the Unknown Interface.
3 Using the “QuerryInterface†and pointer to Unknown Interface get a pointer
to the Dispatch Interface.
4 Use the pointer to the Dispatch Interface and Get Pointer to Workbooks
Interface.
5 Using pointer to WorkBooks interface get the id of "Open" Method.
6 Using the pointer to Workbooks interface "Invoke" the Open Method to open
two Workbooks e.g. Book1.xls and Book2.xls. The Open method also returns
pointers to the two Workbooks.
7 Use the pointer to Workbook2.xls and activate it.
8 Using the pointers to the Workbooks get the pointer to the "Windows"
interface of the two Workbooks.
9 Using pointer to "Windows" interface of Workbook2 all
"CompareSideBySideWith" method on Window name of Workbook1.
10 Using the pointer to Workbook2 call "MergeWorkbook" method on Workbook1.

I am successful in doing until step 8. Step 9 and 10 are failing for me. In
both steps 9 and 10 I am able to get the Id of the method hence I am sure
that I have reached the proper Interface, but calling "Invoke" on the method
fails.
Is there any other property that I have to set (e.g. Shared e.t.c.) before
doing steps 9 and 10 ? Also it would be very helpful if anyone could point me
to a sample code of just step 9 and step 10.

Thanks,
Viraj
http://www.mobiliti.com
732-248-8300 - x234
(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