VBA code in word 2007 for "protect" and "unprotect" buttons

I want to put two buttons inside a word document (word 2007):  Protect and Unprotect.  It's actually a form.  How do I write the code for those two buttons?  I mean, what is the actual code I need to write?
Answer
Answer

It depends on what type of protection you want to apply.  Here is one example.

Sub Prot()
'A basic Word macro coded by Greg Maxey
ActiveDocument.Protect wdAllowOnlyFormFields, True
End Sub
Sub UnProt()
'A basic Word macro coded by Greg Maxey
If ActiveDocument.ProtectionType <> wdNoProtection Then
  ActiveDocument.Unprotect
End If
End Sub

If you are wanting the Classic Formfield tools back then see:

http://gregmaxey.mvps.org/word_tip_pages/add_classic_form_controls.html

Greg Maxey
***
Death smiles at us all, but all a man can do is smile back.


For more help with Word visit:
http://gregmaxey.com/word_tips.html

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 26, 2021 Views 640 Applies to: