w:formProt (Only Allow Editing of Form Fields)
Restricts editing in a section to form field content controls only, preventing changes to the surrounding text when document protection is active.
Parent elements
Description
w:formProt is a toggle element on a section that, when combined with document protection (w:documentProtection in settings.xml), restricts editing in that section to form fields and content controls only. The non-form-field content becomes read-only for the user.
It is defined in ECMA-376 Part 1 §17.6.6.
w:formProt has effect only when the document is protected (w:documentProtection with w:edit="formFields"). Without document protection it has no practical impact.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:val |
ST_OnOff |
true, false, 1, 0, on, off |
Enables or disables form-only protection for the section. Omitting w:val is equivalent to true. |
Examples
<!-- Section locked to form-field editing only -->
<w:sectPr>
<w:formProt/>
<w:pgSz w:w="12240" w:h="15840"/>
</w:sectPr>
<!-- settings.xml — enables document protection -->
<w:settings>
<w:documentProtection w:edit="formFields" w:enforcement="1"/>
</w:settings>
using DocumentFormat.OpenXml.Wordprocessing;
// In the section properties
var sectPr = new SectionProperties(
new FormProtection()
);
// In settings.xml
var settings = new Settings(
new DocumentProtection
{
Edit = DocumentProtectionValues.FormFields,
Enforcement = true
}
);
Notes
w:formProtoperates at the section level; different sections in the same document can have different protection settings.- A section without
w:formProt(or withw:formProt w:val="false") that coexists with a protected section will still be editable even when document protection is on. - Setting
w:formProton the finalw:sectPr(inw:body) protects the entire document body.