lacviet2005
09-18-2006, 05:13 PM
Hi guys,
I have a protected spreadsheet, and I want the user be able to inserting/deleting rows and columns. I searched the forum and didn't find what i want. Anyway, I tried this code:Public Sub Protect_Sheet()
ActiveSheet.Protect Password:="password", DrawingObjects:=True, _
Contents:=True, Scenarios:=True, UserInterfaceOnly:=True, _
AllowInsertingRows:=True, AllowDeletingRows:=True, AllowFiltering:=True, _
AllowInsertingColumns:=True, AllowDeletingColumns:=True
End Sub
But somehow, i can't get it to work. It gives me this error message: "Run-time error '1004': Application-defined or object-defined error."
I tried DRJ's:
Public Sub ProtectAll()
Const PWORD As String = "MySecretWord"
Dim wsSheet As Worksheet
For Each wsSheet In Worksheets
wsSheet.Protect Password:=PWORD, DrawingObjects:=False, _
Contents:=True, Scenarios:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True, UserInterfaceOnly:=True, _
AllowFormattingCells:=True, AllowFormattingRows:=True
Next wsSheet
End Sub
And i got this "Compile error: Named argument not found"
Please help.
Thanks very much.
LV
I have a protected spreadsheet, and I want the user be able to inserting/deleting rows and columns. I searched the forum and didn't find what i want. Anyway, I tried this code:Public Sub Protect_Sheet()
ActiveSheet.Protect Password:="password", DrawingObjects:=True, _
Contents:=True, Scenarios:=True, UserInterfaceOnly:=True, _
AllowInsertingRows:=True, AllowDeletingRows:=True, AllowFiltering:=True, _
AllowInsertingColumns:=True, AllowDeletingColumns:=True
End Sub
But somehow, i can't get it to work. It gives me this error message: "Run-time error '1004': Application-defined or object-defined error."
I tried DRJ's:
Public Sub ProtectAll()
Const PWORD As String = "MySecretWord"
Dim wsSheet As Worksheet
For Each wsSheet In Worksheets
wsSheet.Protect Password:=PWORD, DrawingObjects:=False, _
Contents:=True, Scenarios:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True, UserInterfaceOnly:=True, _
AllowFormattingCells:=True, AllowFormattingRows:=True
Next wsSheet
End Sub
And i got this "Compile error: Named argument not found"
Please help.
Thanks very much.
LV