Can't delete a worksheet

  • Thread starter ragtopcaddy via AccessMonster.com
  • Start date
R

ragtopcaddy via AccessMonster.com

Here's my code:

With XLobj
Set wkbkTpt = .Workbooks.Open(strTptPath)
With wkbkTpt
.Activate
.SaveAs strRptPath
.Close False
End With
Set wkbkRpt = .Workbooks.Open(strRptPath)
With wkbkRpt
.Activate
Set shtTmplt = .Sheets("MarketRpt")
.Save
End With
End With

'**********************************************************
nRows = XLProc(blNewPNL)
'**********************************************************

XLobj.Worksheets("MarketRpt").Delete

Everything works great, except for that last line! When I open the workbook,
the sheet is still there.
 
R

ragtopcaddy via AccessMonster.com

If I change the last line to:

wkbkRpt.Worksheets("MarketRpt").Activate

It correctly has that sheet open when I open the workbook
 
R

ragtopcaddy via AccessMonster.com

The following didn't work:

wkbkRpt.Worksheets("MarketRpt").Activate
XLobj.ActiveSheet.Delete

Although it did find and activate the right sheet.
 
Top