Hi.
Unprotecting is failing for some reason. I am using UserInterfaceOnly:=True but it still complains.
Public Sub SaveWB()
Dim wSh As Worksheet
Set wSh = ThisWorkbook.Worksheets("Summary")
wSh.Unprotect
With Application
.DisplayAlerts = False
.ScreenUpdating = False
On Error Resume Next
wSh.Range("C5").Value = Hour(Now) & ":" & Minute(Now) & ":" & Second(Now) ' Fails here with 1004 error stating the sheet is still protected
If err.Number = 0 Then
ThisWorkbook.Save
If err.Number <> 0 Then
Call ErrMsg(err.Number, err.Description, "Error Saving", "The spreadsheet could not be saved. Please make sure the location where you open it from is still available.")
On Error GoTo 0
End If
End If
.ScreenUpdating = True
.DisplayAlerts = True
End With
wSh.Protect UserInterfaceOnly:=True
Set wSh = Nothing
End Sub
Hope someone has some insights.
Thanks
Unprotecting is failing for some reason. I am using UserInterfaceOnly:=True but it still complains.
Public Sub SaveWB()
Dim wSh As Worksheet
Set wSh = ThisWorkbook.Worksheets("Summary")
wSh.Unprotect
With Application
.DisplayAlerts = False
.ScreenUpdating = False
On Error Resume Next
wSh.Range("C5").Value = Hour(Now) & ":" & Minute(Now) & ":" & Second(Now) ' Fails here with 1004 error stating the sheet is still protected
If err.Number = 0 Then
ThisWorkbook.Save
If err.Number <> 0 Then
Call ErrMsg(err.Number, err.Description, "Error Saving", "The spreadsheet could not be saved. Please make sure the location where you open it from is still available.")
On Error GoTo 0
End If
End If
.ScreenUpdating = True
.DisplayAlerts = True
End With
wSh.Protect UserInterfaceOnly:=True
Set wSh = Nothing
End Sub
Hope someone has some insights.
Thanks