From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Loops through worksheets Excel

Solved!
Go to solution

Hello,

 

I tried to loop through the worksheets in and Excel doc by increasing the work sheet handle. But unfortunately that does not seem to be possible and I got an error.

 

	ExcelRpt_SetWorksheetAttribute(rawDataWorkSheetHandle,ER_WS_ATTR_NAME,"Analysis Data");
	__caErrChk(ExcelRpt_SetWorksheetAttribute(rawDataWorkSheetHandle+1,ER_WS_ATTR_NAME,"something")); 

 

Is it somehow possible to do that? I don't like haven a handle for every worksheet in my workbook..

 

Thanks!

0 Kudos
Message 1 of 2
(4,369 Views)
Solution
Accepted by topic author ZerMahlMeer
Hi,

Like it or not, you need to get the worksheet handle if you want to access worksheet attributes.
There is a function named ExcelRpt_GetWorksheetFromIndex for that purpose.

This function outputs the worksheet handle if you provide its 1-based index.
Beware that You have to call CA_DiscardObjHandle after you are done with that worksheet.

So both functions above should be inside your for-loop.
S. Eren BALCI
IMESTEK
Message 2 of 2
(4,353 Views)