LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

read Excel footer using excel 2000 api

Hi,
 I want to read the excel right footer information.
I use Excel_GetProperty (ExcelWorksheetHandle, NULL, Excel_PageSetupRightFooter, CAVT_CSTRING, footerInfo);
this function gives me an error "This handle is invalid".
any suggestions?
 
Thanks
0 Kudos
Message 1 of 3
(3,276 Views)
The worksheets handle does not validly represent an Excel worksheet page setup object. The flow needs to go as such: Get application handle, get workbooks handle, good workbook handle, get sheets handle, get sheet handle, get page setup handle, and then reference this page setup handle to get the footer property.

Consider this snippet:

error = Excel_NewApp (NULL, 1, LOCALE_NEUTRAL, 0, &ExcelAppHandle);
         
// Make app visible
error = Excel_SetProperty (ExcelAppHandle, NULL, Excel_AppVisible, CAVT_BOOL, VTRUE);
   
// Get Workbooks   
error = Excel_GetProperty (ExcelAppHandle, NULL, Excel_AppWorkbooks, CAVT_OBJHANDLE, &ExcelWorkbooksHandle);
       
// Get Workbook
error = Excel_WorkbooksOpen (ExcelWorkbooksHandle, NULL, "C:\\test.xls", 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);
           
// Get Active Workbook Sheets
error = Excel_GetProperty (ExcelAppHandle, NULL, Excel_AppSheets, CAVT_OBJHANDLE, &ExcelSheetsHandle);
           
// Get First Sheet
error = Excel_SheetsItem (ExcelSheetsHandle, NULL, CA_VariantInt(1), &ExcelWorksheetHandle);
   
// Get page setup object
error = Excel_GetProperty (ExcelWorksheetHandle, NULL, Excel_WorksheetPageSetup, CAVT_OBJHANDLE, &pageSetup);
           
// Get right footer information
error = Excel_GetProperty (pageSetup, NULL, Excel_PageSetupRightFooter, CAVT_CSTRING, &footerInfo);

SetCtrlVal (panelHandle, PANEL_STRING, footerInfo);

// Check for ActiveX errors
CA_GetAutomationErrorString (error, errorCode, 256);

Hope this helps!



Evan Prothro
RF Systems Engineer | NI

0 Kudos
Message 2 of 3
(3,244 Views)
thanks for the answer, it worked
0 Kudos
Message 3 of 3
(3,190 Views)