Page 1 of 1

Select different worksheet in Excel

Posted: Fri Aug 07, 2009 1:14 pm
by ConvertFromOldNGs
by Stevek >> Thu, 8 Nov 2007 6:01:52 GMT

Can anyone suggest (by example) how to code a switch in worksheet once an Excel object (workbook) has been created - with a default of 3 worksheets. I have a process that needs to generate 3 worksheets and while I can select the default (activeSheet), I cannot see how to activate the other sheets when required.

I can follow the logic in Excel when using Macros to see what MS does but cannot translate the process to jade coding.

Re: Select different worksheet in Excel

Posted: Fri Aug 07, 2009 1:14 pm
by ConvertFromOldNGs
by Justin >> Mon, 24 Dec 2007 1:45:16 GMT

hope bolow example can help you,
//xl is Excel Activex object ,wBook is a Excel workbook
wBook := xl.workbooks.add(xl.XlWorksheet);
wBook.worksheets.add(xl.activeSheet,null, 2, null); //add 2 worksheet in current workbook
wBook.worksheets.p_Default("sheet2").I_Worksheet.activate() ;//"sheet2" is the sheet's name you want to actived


Regards,
Justin Chen