Remove excel sheet

Hi,

I try to export Lotus Notes documents to Excel. I add new sheet for every document. My problem is, that I cannot delete the “default” sheets from Excel.

Can anybody tell me how to delete this sheets?

Thks

Attila

Subject: Remove excel sheet

Dear Attilla

The Worksheets collection count property will tell you how many sheets there are in a new workbook(default is 3, but this is customisable by the user).

You can’t remove all the sheets to leave none, so suggest easiest thing for you would be to remove the ‘default’ sheets after you have finished creating all your new sheets for your documents. You can refer to them by name in the worksheets array to do this e.g.

xlWorksheets(“Sheet1”).Delete

xlWorksheets(“Sheet2”).Delete

where xlWorksheets is a variant variable pointing to the Worksheets object contained by the current Workbook.

Subject: RE: Remove excel sheet

Dear Melissa,

Thanks for your help. It is working now. I made only one change, I’m using numbers instead of Sheet name, because the Microsoft translated them to several languages and I’m not sure if the user has english or hungarian Excel.

Other question is how can I get how many “default” sheets has the user on Excel?

Attila

Subject: RE: Remove excel sheet

You can specify the number of worksheets you want in your workbook when you instantiate your Excel object this way:

Set xlApp = createObject("Excel.application")

xlapp.visible=True



xlapp.SheetsInNewWorkbook = 4

xlapp.workbooks.add