Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

How to lock styles, remove protection, then protect doc in 2003?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kckc - 08 Feb 2006 14:36 GMT
I'm trying to lock styles only, when the doc opens (user will be able to edit
doc). Before saving, i want to remove the password protect, set all section
protectionforforms to true, then reprotect doc as well as lock styles.  When
I try to set the protectionforforms, I get an error "Command not available
because document is password-protected".  I ran the below macros in the order
from top to bottom for demo purposes and got the error.  I have a work around
(before I set the protectionforforms, I protect the document with
Type:=wdAllowOnlyFormFields, unprotect it, set the protectionforforms, then
reprotect.)  It sounds kind of silly, so I'm asking if there's a better way.

Public Sub Lock_Styles_Only()
   ActiveDocument.Protect Type:=wdNoProtection, _
       noreset:=False, Password:="pass", enforcestylelock:=True
End Sub

Public Sub Remove_Protection()
   ActiveDocument.unprotect ("pass")
End Sub

Public Sub Protect_Doc_and_Lock_Styles()
   Dim sec As Section
   For Each sec In ActiveDocument.Sections
       sec.ProtectedForForms = True 'error occurs here
   Next sec
   ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
       noreset:=False, Password:="lawp", enforcestylelock:=True
End Sub
kckc - 08 Feb 2006 14:51 GMT
please assume that all the passwords below are the same.  I forgot to change
them all on this demo.

> I'm trying to lock styles only, when the doc opens (user will be able to edit
> doc). Before saving, i want to remove the password protect, set all section
[quoted text clipped - 23 lines]
>         noreset:=False, Password:="lawp", enforcestylelock:=True
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.