LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Make Excel-sheet 2 visible

I write an application, in which I want to transfer data into an Excel-sheet. I also can transfer data in sheet 2, but this sheet must be active (does not work if sheet 1 is active).
Can I use the following function to activate sheet 2, and what changes have to be done ? The functions is in the exceldem97.c file included.

function:
// Make First Sheet Visible - should already be visible //,
error = Excel_SetProperty (ExcelWorksheetHandle, NULL, Excel_WorksheetVisible,
CAVT_LONG, ExcelConst_xlSheetVisible);
0 Kudos
Message 1 of 3
(3,153 Views)
I'm afraid you are going to have an endless array of questions like this until you get used to ActiveX programming. This function is setting the sheet to visible, not to active. To set a worksheet active, you can use the function:

Excel_WorksheetActivate (ExcelWorksheetHandle, NULL);

Where ExcelWorksheetHandle is the handle of the sheet you want to make active.

Best Regards,

Chris Matthews
Measurement Studio Support Manager
0 Kudos
Message 2 of 3
(3,153 Views)
This is probably a very stupid question, but how do I acquire the handle of the desired worksheet? In my application, I use;

// Get Active Workbook Sheets
Excel_GetProperty (ExcelAppHandle, NULL, Excel_AppSheets,CAVT_OBJHANDLE, &ExcelSheetsHandle);

but this will only return the sheet which is active at the moment. (i.e. the sheet that was active by default when opening my resultsfile)

This means that if I would save the workbook with the wrong sheet selected, the resultprinting would take place on the wrong sheet. (I want to have one sheet where all source data from my application goes, then have other sheets for graphical result)

For example, how do I select a sheet called "Source"?

I've tried to use;
Excel_WorksheetSelect (CAObjHandle
objectHandle,
ERRORINFO *errorInfo, VARIANT replace);
..but I don't understand the use of VARIANT replace.

Any tips or documentation are welcome!
0 Kudos
Message 3 of 3
(3,152 Views)