Bob Rowley
New Member
- Joined
- Apr 14, 2019
- Messages
- 5
Hi Hope someone can help, I have had some code that works perfectly with windows excel 2003 but the code fails in excel any later versions, and suggestions would be very gratefully received.
Option Explicit
Private Sub Workbook_Open()
Dim wSht As Worksheet
Dim PW As String
PW = "mypassword"
'set protection using UserInterface to allow macros to work
For Each wSht In ActiveWorkbook.Sheets
wSht.Protect _
Password:=PW, _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
UserInterfaceOnly:=True
Next wSht
End Sub
Option Explicit
Private Sub Workbook_Open()
Dim wSht As Worksheet
Dim PW As String
PW = "mypassword"
'set protection using UserInterface to allow macros to work
For Each wSht In ActiveWorkbook.Sheets
wSht.Protect _
Password:=PW, _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
UserInterfaceOnly:=True
Next wSht
End Sub