S
Sonny Maou
I'd like to be able to protect a workbook from changes via VBA. In Word,
I have these two bits of code...
Sub LockItUp(doit)
If doit <> wdNoProtection Then
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=doit, NoReset:=True,
Password:="myPass1234"
End If
End If
End Sub
Function UnlockIt()
Dim wasLocked
wasLocked = ActiveDocument.ProtectionType
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect "myPass1234"
End If
UnlockIt = wasLocked
End Function
The function UnLockIt() simply locks up a document with a password and
returns what the prior protection scheme was. LockItUp() simply locks it
back up with whatever parameter it is given. I usually run these during
save, close, open, etc...
I generally know now how to do it in Excel, but how do I do it most
effectively?
Thanks!
I have these two bits of code...
Sub LockItUp(doit)
If doit <> wdNoProtection Then
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=doit, NoReset:=True,
Password:="myPass1234"
End If
End If
End Sub
Function UnlockIt()
Dim wasLocked
wasLocked = ActiveDocument.ProtectionType
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect "myPass1234"
End If
UnlockIt = wasLocked
End Function
The function UnLockIt() simply locks up a document with a password and
returns what the prior protection scheme was. LockItUp() simply locks it
back up with whatever parameter it is given. I usually run these during
save, close, open, etc...
I generally know now how to do it in Excel, but how do I do it most
effectively?

Thanks!