How do I open a empty workbook with no sheets?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using this line.

myWorkbook = myExcelApp.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);

But, it is giving me an empty sheet to start out with. I have also tried
using Type.missing, but that gives me 3 empty sheets.
 
Excel requires that an open workbook has at least one visible
worksheet. Sorry, but I don't see a way to have a workbook without any
worksheets.

If you want an empty vessel for some code, you might want to think
about saving your workbook as an excel add-in. But I'm not really sure
what you need, so I hope you find something that works.

-JK
 
Well, I do have other sheets that I am adding, but I always have this one
sheet named "Sheet1" that I can't seem to do anything with. Is there a way
to Select and Delete it?
 
In Excel, I do this kind of thing:

dim myWorkbook as workbook
set myworkbook = workbooks.add(1) 'single sheet, same as xlwbatworksheet
myworkbook.worksheets(1).name = "DeleteMeLater"
'do a bunch of stuff
'later
application.displayalerts = false
myworkbook.worksheets("deletemelater").delete
application.displayalerts = true

======
If you always add sheets to the right of worksheets(1), you could drop the
naming stuff and just delete the first worksheet.
 
Back
Top