dipitiduda2
Technical User
Hello,
I'm trying to use the ThisWorkbook.Open() event in an xl97 workbook (code originally written in xl2002) with multiple worksheets to .Protect/.Unprotect the macros running within each worksheet.
The macros run correctly on the first fire, but upon the creation (using ActiveSheet.CopyAfter:=ActiveSheet) of another worksheet in the workbook, the macros are disabled in the new worksheets. The number of worksheets to be copied into the workbook is unknown.
I also had to change the syntax of the ThisWorkbook_Open() macro event from xl2002 to xl97 to allow for one of the arguments set to = False. See code below.
Problem: In xl97 I cannot find the correct syntax that will allow me to .Protect/.Unprotect "For Each ws In ThisWorkbook.Worksheets.Protect....
Here's my code for the open event:
I know I'm missing the .Protect/.Unprotect code, but cannot figure out how to say, "apply these arguments to each worksheet in this workbook whether named or not" in this event.
Any assistance is greatly appreciated. I have looked on every web site that I can find for the answer, but to no avail.
![[dazed] [dazed] [dazed]](/data/assets/smilies/dazed.gif)
I'm trying to use the ThisWorkbook.Open() event in an xl97 workbook (code originally written in xl2002) with multiple worksheets to .Protect/.Unprotect the macros running within each worksheet.
The macros run correctly on the first fire, but upon the creation (using ActiveSheet.CopyAfter:=ActiveSheet) of another worksheet in the workbook, the macros are disabled in the new worksheets. The number of worksheets to be copied into the workbook is unknown.
I also had to change the syntax of the ThisWorkbook_Open() macro event from xl2002 to xl97 to allow for one of the arguments set to = False. See code below.
Problem: In xl97 I cannot find the correct syntax that will allow me to .Protect/.Unprotect "For Each ws In ThisWorkbook.Worksheets.Protect....
Here's my code for the open event:
Code:
Private Sub Workbook_Open()
'Tasks to be completed each time the file is opened:
Sheets("Instructions").Select
Begin_Form.Show
On Error Resume Next
For Each Sh In ThisWorkbook.Worksheets
Password:="texas", _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=False, _
UserInterfaceOnly:=True
Next
End Sub
I know I'm missing the .Protect/.Unprotect code, but cannot figure out how to say, "apply these arguments to each worksheet in this workbook whether named or not" in this event.
Any assistance is greatly appreciated. I have looked on every web site that I can find for the answer, but to no avail.
![[dazed] [dazed] [dazed]](/data/assets/smilies/dazed.gif)