LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Protecting/Unprotecting Workbook

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!


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Protecting and Unprotecting several worksheets at one time Learning Excel Excel Discussion (Misc queries) 8 February 4th 09 10:07 PM
protecting and unprotecting Fusion1337 Excel Worksheet Functions 5 September 26th 08 04:03 PM
PROTECTING/UNPROTECTING SHEETS Maureen Excel Discussion (Misc queries) 1 January 6th 05 06:46 PM
Protecting and Unprotecting multiple sheets pkley Excel Programming 3 January 22nd 04 05:26 PM
Protecting & unprotecting worksheets pkley Excel Programming 1 January 7th 04 10:28 PM


All times are GMT +1. The time now is 02:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"