Do While owb.Sheets.Count > 1 mname=owb.Sheets(2).Name Wait Window 'removing '+ mname timeout 2 owb.Sheets(2).Delete Enddo>looping from highest # down to first might be more stable...
>>>>lcFile='myfile.xlsx' >>>>Erase (Forceext(lcFile,'xxx')) >>>>ox=Createobject('excel.application') >>>>owb=ox.Workbooks.Open(lcFile) >>>> >>>>If owb.Sheets.Count > 1 >>>> Nu= owb.Sheets.Count >>>> ms=1 >>>> Do While ms < Nu+1 >>>> mname=owb.Sheets(m1).Name >>>> If ms>1 >>>> Wait Window 'removing '+ mname timeout 2 >>>> owb.Sheets(mname).Delete >>>> Endif >>>> ms=ms+1 >>>> Enddo >>>>Endif >>>>ox.Visible=.T. >>>>>>>
>>>lcFile='myfile.xlsx' >>>ox=Createobject('excel.application') >>>owb=ox.Workbooks.Open(lcFile) >>> >>>If owb.Sheets.Count > 1 >>> Nu= owb.Sheets.Count >>> Do While Nu > 1 >>> mname=owb.Sheets(Nu).Name >>> Wait Window 'removing '+ mname timeout 2 >>> owb.Sheets(mname).Delete >>> Nu= owb.Sheets.Count >>> Enddo >>>Endif >>>ox.Visible=.T. >>>