We help IT Professionals succeed at work.

Only allow input into content controls

Andrew Crofts
Andrew Crofts used Ask the Experts™
on
Word 2007

I have had a request to prevent users entering text anywhere other than into content controls.

How can this be achieved?

TIA
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
GrahamSkanRetired
Top Expert 2012

Commented:
Forms protection will do that. Open the 'Restrict Formatting and Editing' task pane with the Protect document button on the Developer tab. Tick the checkbox in section 2 and select 'Filling in forms' and then 'Yes, Start Enforcing Protection'. You can provide a password to prevent easy protection removal.

Author

Commented:
Can this be done from a template and therefore applies to any document opend using this template?
GrahamSkanRetired
Top Expert 2012

Commented:
Yes, no problem. Just Protect and Save.

Author

Commented:
Thanks

Couldn't seem to get the protection in the template to apply to the documents associated with it but for the time being that isn't the most important bit.

We have a custom tool bar where users can add content controls of various types. With the protection on, these cannot be added.

Not sure how I can get round this unless I can control the protection programmatcally. Ie turning off protection to insert new controls then back to allowing input only to the controls.

Can the control of protection be done programmatically? If so how.
Retired
Top Expert 2012
Commented:
Documents created from a template will reflect the content, including the protection status at creation time. Once created the only reference to the template is for styles, macros, etc. Later changes to the template won't change the content of  the documents.

Here is some code to switch protection on and off
Sub RemoveFormsProtection()
    If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
        ActiveDocument.Unprotect 'password
    End If
End Sub
Sub AddFormsProtection()
    If ActiveDocument.ProtectionType = wdNoProtection Then
        ActiveDocument.Protect wdAllowOnlyFormFields, True ',password
    End If
End Sub

Open in new window

Author

Commented:
Thanks

I think this might work but it leads me to another problem for which I will raise another question.

I'll do this when I get back to looking at this