WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Excel
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Add New Worksheet

 Keywords: add worksheet workbook Excel 

Question:

How do you add a worksheet once you open Excel and create one?

Answer:

To add a new worksheet, you use the ADD method of the worksheets collection. Setup a reference to the worksheets collection then use .add
Function Add([Before], [After], [Count], [Type]) As Object
    Member of Excel.Worksheets

Here's how to add a blank workbook...
:startExcel
   ;   Start excel here
   excelxls = objectopen("Excel.Application")
   excelxls.visible = @false
   rptxls = excelxls.workbooks
   ;   add a blank workbook...
   rptxls.add
   ;   setup the sheets var...
   xsheets = excelxls.sheets
   objectclose(rptxls)
return


Article ID:   W15624
File Created: 2003:05:13:11:29:18
Last Updated: 2003:05:13:11:29:18