hi guys, some of you knows if in different version of excel the protection VBA code is the same ?
any differences ?
i have a class module called Data manager in which i have this function
Private Sub ProtectAllSheets(ByVal block As Boolean, Optional ByVal onlySystem As Boolean)
On Error Resume Next
If (onlySystem) Then
If (block) Then
Call Sheets("system").Protect
Call Sheets("s2").Protect(SHEET_PROTECT)
Call Sheets("s3").Protect(SHEET_PROTECT)
Call Sheets("s4").Protect(SHEET_PROTECT)
Call Sheets("s5").Protect(SHEET_PROTECT)
Else
Call Sheets("s2").Unprotect(SHEET_PROTECT)
Call Sheets("23").Unprotect(SHEET_PROTECT)
Call Sheets("24").Unprotect(SHEET_PROTECT)
Call Sheets("25").Unprotect(SHEET_PROTECT)
End If
Else
Dim sheet As Worksheet
For Each sheet In Sheets
If (block) Then
If (loginStatus = LOGGED_AS_ADMIN) Then
Call sheet.Protect(SHEET_PROTECT, AllowInsertingRows:=True, AllowDeletingRows:=True)
ElseIf (loginStatus = LOGGED_IN And ReturnCellStatus(sheet)) Then
Call sheet.Protect(SHEET_PROTECT, AllowInsertingRows:=True, AllowDeletingRows:=True)
Else
Call sheet.Protect(SHEET_PROTECT, AllowInsertingRows:=False, AllowDeletingRows:=False)
End If
Else
Call sheet.Unprotect(SHEET_PROTECT)
End If
Next
End If
End Sub
and it works fine in excel 2003 but when it runs on excel 2007 and excel 2010 cause some problem in the sheet content. some chart and button changes their position when the sheet is protected.. even if theese object are linked to a specific cell...
anyone who can help me ?
bye and thanks :D
Bookmarks