Ask a Question

Removing Default Excel Sheets

TomY
Occasional Contributor

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 1


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.
--
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: