w:locked (Locked Style)
Prevents a style from being modified or deleted by end-users when document protection is active.
Parent elements
Description
w:locked is a toggle element on a w:style that, when document protection is enabled (w:documentProtection with w:edit="formFields" or similar), prevents users from modifying or deleting that style.
It is defined in ECMA-376 Part 1 §17.7.4.7.
Without active document protection, w:locked has no visible effect — it is only enforced when the document is protected.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:val |
ST_OnOff |
true, false, 1, 0, on, off |
Enables or disables the lock. Omitting w:val is equivalent to true. |
Examples
<w:style w:type="paragraph" w:styleId="Heading1">
<w:name w:val="heading 1"/>
<w:locked/>
<!-- pPr and rPr omitted -->
</w:style>
using DocumentFormat.OpenXml.Wordprocessing;
var style = new Style(
new StyleName { Val = "heading 1" },
new Locked()
)
{
Type = StyleValues.Paragraph,
StyleId = "Heading1"
};
Notes
w:lockedtakes effect only when document protection is enabled viaw:documentProtectioninsettings.xml.- When locked and the document is protected, users cannot modify the style definition through the UI.