Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have been looking for documentation - any documentation or better yet, real
code examples regarding the c++ objects and methods for excel 2003. My progress has been based on reverse engineering and guessing so is quite slow. Help! My purpose is exceptionally simple, to read (only, not write or format) data from excel workbooks/worksheets. I have a c++ MFC DLL project and have created excel classes from the type library (actually .../EXCEL.EXE). The trouble really starts there - the imported classes won't compile without some hand editing (Is that expected?). After some "fixing," I can start the app with the following code: if(!app.CreateDispatch(L"Excel.Application")) { //...todo - add error handling and cleanup return; } else { //Make the app visible and verify the name - just for kicks! COleVariant covOptional(DISP_E_PARAMNOTFOUND,VT_ERROR); app.put_Visible(TRUE); app.put_UserControl(TRUE); CString appName = app.get_Name(); ... } But that's where I'm stuck. I can't open an existing workbook because I don't know what to supply for the workbook methods to open an existing workbook. Brining up any of the dialogs (such as app._FindFile()) control is transferred to the app (away from my DLL) and is not returned until I dismiss the dialog manually. Needless to say, that's definitely not useful.... Here's the code I'm currently playing with: COleVariant covOptional(DISP_E_PARAMNOTFOUND,VT_ERROR); ExcelWorkbooks excelWBs = app.get_Workbooks(); ExcelWorkbook excelWB; appName = app.get__Default(); ExcelParameter excelParam = excelWBs.get__Default(COleVariant((short)2)); excelWBs.Add(_T(".\\ExcelExample.xls"),covOptional , (ExcelParameter **)&excelParam); I've gotten this far by reverse engineering and poking around on Google -- VERY FRUSTRATING to spend several hours to get 10 lines of code for something so trivially simple. The VB and C# examples are plentiful and I can make those work easily. But for many reasons this has to be a C++ project. If could point me to any c++ code examples or documentation I would be greatly relieved! ;-) Thanks in advance. dan |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Where is documentation for the C# Office XP/2003 Primary Interop Assemblies??? | Excel Programming | |||
Documentation of Excel 2003 objects | Excel Programming | |||
Excel Notation for Documentation? | Excel Programming | |||
Look up VBA documentation using Excel Help | Excel Programming | |||
Excel Object Documentation | Excel Programming |