Link to home
Start Free TrialLog in
Avatar of jforbes
jforbes

asked on

Programmatically Creating/Deleting/Renaming Excel Worksheets

I am currently developing a project in Access that takes data and stores it in arrays, and then spits out an Excel Report that can be edited.  What I need to be able to do is delete sheet2 and sheet3 from the newly created object and rename Sheet1.  The following is a snipet of code that I have been using.

   Set ExcelApp = New Excel.Application
   ExcelApp.Visible = True
     
   ExcelApp.Workbooks.Add
   Set Excelbook = ExcelApp.ActiveWorkbook
   
   Set ExcelSheet = Excelbook.Worksheets("Sheet2")

   ExcelSheet.Delete
   ExcelSheet.Activate

this works for deleting but Excel wants an answer if deleting is okay, is there a param I send send like I do when I save.  Also I would like to know how to change the Sheet name from Sheet1 to like Test1.  Thanks in advance, any help is greatly appreciated.

-John
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jforbes
jforbes

ASKER

Thanks Bro!! Works like a charm.