G
Gary Adamson
I have a routine that should go through and delete the
shapes and other sheets in an Excel workbook.
The problem is that the button(shape) that is clicked to
perform this operation is not deleted. Also the sheet
doesn't want to delete as well.
Sub CreateSheet()
Dim Shp As Shape, i As Integer, FName, WName
FName = ActiveWorkbook.FullName
WName = ActiveWorkbook.Path & "\Week" & Range("A2")
ActiveWorkbook.Save
With thisworkbook.ActiveSheet
.Unprotect
On Error Resume Next
For Each Shp In .Shapes
Shp.Visible = False
Next Shp
Application.DisplayAlerts = False
For i = 1 To Sheets.Count
If Sheets(i).Name <> "Current" Then .Sheets(i).Delete
Next i
Application.DisplayAlerts = False
.Protect
End With
ActiveWorkbook.SaveAs Filename:=WName
Workbooks.Open Filename:=FName
thisworkbook.Close
End Sub
shapes and other sheets in an Excel workbook.
The problem is that the button(shape) that is clicked to
perform this operation is not deleted. Also the sheet
doesn't want to delete as well.
Sub CreateSheet()
Dim Shp As Shape, i As Integer, FName, WName
FName = ActiveWorkbook.FullName
WName = ActiveWorkbook.Path & "\Week" & Range("A2")
ActiveWorkbook.Save
With thisworkbook.ActiveSheet
.Unprotect
On Error Resume Next
For Each Shp In .Shapes
Shp.Visible = False
Next Shp
Application.DisplayAlerts = False
For i = 1 To Sheets.Count
If Sheets(i).Name <> "Current" Then .Sheets(i).Delete
Next i
Application.DisplayAlerts = False
.Protect
End With
ActiveWorkbook.SaveAs Filename:=WName
Workbooks.Open Filename:=FName
thisworkbook.Close
End Sub