oldOnError=on('error') on Error oExcel=.NULL. oExcel=getobject(,'Excel.Application') on error &oldOnError if isnull(oExcel) oExcel=createobject('Excel.Application') endif With oExcel .WorkBooks.Add .displayalerts=.f. nWorkBookSheets=.Sheets.Count for c=nWorkBookSheets to 2 step -1 .sheets(c).delete endfor .Cells(1,1).Value=[Insert row above this line] .Range("A1").Select .Selection.EntireRow.Insert oExcel.Visible=.t. endwith