This isn't the way ActiveX programming works. The workbook has to opened INSIDE the context of the application object that you created with Excel_NewApp. In ActiveX, this relationship is managed through collections. The Application object (that you created with Excel_NewApp) has a collection of workbooks. To open a workbook in that application, you have to get the collection of workbooks from the application object and then open the workbook inside that collection. You can see how this is done in the example you referred to in the OpenAppFile function. First, it gets the application object's workbooks collection with:
error = Excel_GetProperty (ExcelAppHandle, NULL, Excel_AppWorkbooks, CAVT_OBJHANDLE, &ExcelWorkbooksHandle);
Then, it opens a workboo
k from a file and adds it to that collection with:
error = Excel_WorkbooksOpen (ExcelWorkbooksHandle, NULL, fileName, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, &ExcelWorkbookHandle);
Hopefully that makes sense. It takes some time to get used to ActiveX programming and the object relationships like collections. The example you referred to is a good reference for the excel objects.
Best Regards,
Chris Matthews
National Instruments