Forum Discussion

TomY's avatar
TomY
Occasional Contributor
14 years ago

Removing Default Excel Sheets

When creating a new Excel object, it creates 3 default sheets.  How do I remove these extra sheets?



  xclD       = Sys.OleObject("Excel.Application");

  workBkDarwin    = xclD.Workbooks.Add();

 

// remove default sheets



  workSheetEvent = workBkDarwin.Sheets.Add();

  workSheetEvent.Name = "Event";

 

1 Reply


  • Hi,





    Add the code below at the end of the given code to do what you need:





        for(i = 2; i <= workBkDarwin.Sheets.Count; i++)    {

            workBkDarwin.Sheets.Item(i).Delete();

        }











    BTW, we provide support only for AutomatedQA products, but not for the Excel object model.