A
AMK4
Can someone explain to me why this fails in Excel 2000? They're getting
an error: *Microsoft Visual Basic Compile Error: Named Argument Not
Found*
Code:
--------------------
Private Sub Workbook_Open()
Dim wSheet As Worksheet
Application.ScreenUpdating = False
If Worksheets("MasterData").Visible = True Then
' MasterData is visible, keep everything veryhidden
For Each wSheet In Worksheets
wSheet.Unprotect Password:="cookies2006"
wSheet.EnableSelection = xlUnlockedCells
If wSheet.Name <> "MasterData" Then
wSheet.Protect Password:="cookies2006", Contents:=True, UserInterfaceOnly:=True
wSheet.Visible = xlSheetVeryHidden
Else
wSheet.Protect Password:="cookies2006", Contents:=True, UserInterfaceOnly:=True, AllowFormattingColumns:=True
wSheet.Visible = xlSheetVisible
End If
Next
Else
' MasterData has been hidden, don't hide other sheets
For Each wSheet In Worksheets
If wSheet.Visible = True Then
' the sheet's not hidden, un/relock, don't hide
wSheet.Unprotect Password:="cookies2006"
wSheet.EnableSelection = xlUnlockedCells
wSheet.Protect Password:="cookies2006", Contents:=True, UserInterfaceOnly:=True
End If
Next
End If
Application.ScreenUpdating = True
End Sub
an error: *Microsoft Visual Basic Compile Error: Named Argument Not
Found*
Code:
--------------------
Private Sub Workbook_Open()
Dim wSheet As Worksheet
Application.ScreenUpdating = False
If Worksheets("MasterData").Visible = True Then
' MasterData is visible, keep everything veryhidden
For Each wSheet In Worksheets
wSheet.Unprotect Password:="cookies2006"
wSheet.EnableSelection = xlUnlockedCells
If wSheet.Name <> "MasterData" Then
wSheet.Protect Password:="cookies2006", Contents:=True, UserInterfaceOnly:=True
wSheet.Visible = xlSheetVeryHidden
Else
wSheet.Protect Password:="cookies2006", Contents:=True, UserInterfaceOnly:=True, AllowFormattingColumns:=True
wSheet.Visible = xlSheetVisible
End If
Next
Else
' MasterData has been hidden, don't hide other sheets
For Each wSheet In Worksheets
If wSheet.Visible = True Then
' the sheet's not hidden, un/relock, don't hide
wSheet.Unprotect Password:="cookies2006"
wSheet.EnableSelection = xlUnlockedCells
wSheet.Protect Password:="cookies2006", Contents:=True, UserInterfaceOnly:=True
End If
Next
End If
Application.ScreenUpdating = True
End Sub