Paul Hartland
paul.hartland at googlemail.com
Wed Feb 26 09:37:00 CST 2014
Rocky , Just nicked a bit of your code from a previous message, have you tried (off top of my head),: Dim objXLApp As Excel.Application Dim objXLBook As Excel.Workbook Dim objXLWS As Excel.Worksheet I set objXLApp - Set objXLApp = New Excel.Application - and open a new worksheet: Set objXLBook = objXLApp.Workbooks.Open(Me.txtOutputFileName) ' add your new sheet, unless already done ' now firstly try to delete with individual code. objXLApp.displayalerts = False objXLApp.Sheets("Sheet1").Select objXLApp.ActiveSheet.Delete objXLApp.Sheets("Sheet2").Select objXLApp.ActiveSheet.Delete objXLApp.Sheets("Sheet3").Select objXLApp.ActiveSheet.Delete xlBook.Saveas ("your filename") objXLApp.displayalerts = True objXLApp.Sheets("your new sheet name").Select objXLApp.Quit Set objXLBook = Nothing Set objXLApp = Nothing Paul On 30 January 2014 15:40, Rocky Smolin <rockysmolin at bchacc.com> wrote: > Dear List: > > I'm automating a spreadsheet from Access (2003) and importing a worksheet > from another excel file as a template. I want to delete the default > worksheets Sheet1, Sheet2, and Sheet3 but can't seem to get the right > syntax > going. > > Any pointers on how to get this done? > > MTIA > > Rocky Smolin > Beach Access Software > 858-259-4334 > www.bchacc.com <http://www.bchacc.com/> > www.e-z-mrp.com <http://www.e-z-mrp.com/> > Skype: rocky.smolin > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > -- Paul Hartland paul.hartland at googlemail.com