Kbase 20990: ACTIVEX - How to Insert a Worksheet after a Specific One.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  12/11/2002 |
|
Solution ID: 20990
GOAL:
How to add a new worksheet after a specified worksheet.
FIX:
By default a new Excel worksheet is added before the last worksheet.
The worksheets' Add method contains 4 optional arguments:
[ Com-Handle-Var = ] <com-handle>:Add (
<anytype>-Before,
<anytype>-After,
<anytype>-Count,
<anytype>-Type )
The following code has been tested with Microsoft Excel 97.
DEFINE VARIABLE hExcel AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hSheet1 AS COM-HANDLE NO-UNDO.
/* Start Excel */
CREATE "excel.application" hExcel.
/* Make it visible */
hExcel:visible = true.
/* Open a specific file */
hExcel:Workbooks:Open("c:\myFile.xls").
hSheet1 = hExcel:workbooks:item(1):worksheets("sheet1").
/* Add the worksheet AFTER sheet1 */
hExcel:workbooks:item(1):worksheets:add(,hSheet1).
RELEASE OBJECT hSheet1.
RELEASE OBJECT hExcel.