E
EdgeOfCity
worksheets("sheet2") has been protected from "Tool" menu with password
"test".
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim i As Integer
With Worksheets("sheet2")
.Activate
.Unprotect Password:="test"
On Error Resume Next
.Cells(4, 4) = "HI"
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True,
Password:="test"
End With
ActiveWorkbook.Close SaveChanges:=True
End Sub
the question is that why should add "On error resume next"?
"test".
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim i As Integer
With Worksheets("sheet2")
.Activate
.Unprotect Password:="test"
On Error Resume Next
.Cells(4, 4) = "HI"
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True,
Password:="test"
End With
ActiveWorkbook.Close SaveChanges:=True
End Sub
the question is that why should add "On error resume next"?