w:lock (Structured Document Tag Locking)

Specifies whether the structure, content, or both of a structured document tag can be edited by a user.

Parent elements

Description

w:lock controls the edit restrictions on an SDT. It can prevent the user from deleting the SDT container, editing its content, or both.

It is defined in ECMA-376 Part 1 §17.5.2.20.

Attributes

Attribute Type Possible Values Description
w:val ST_Lock unlocked, sdtLocked, contentLocked, sdtContentLocked Locking mode.

Values

Value Description
unlocked No restriction; the SDT and its content can be freely edited.
sdtLocked The SDT container cannot be deleted, but its content can be edited.
contentLocked The content cannot be edited, but the SDT container can be deleted.
sdtContentLocked Both the container and content are locked — no editing or deletion is possible.

Examples

<!-- SDT that cannot be deleted, but its content can be changed -->
<w:sdtPr>
  <w:alias w:val="Approval Date"/>
  <w:lock w:val="sdtLocked"/>
  <w:date/>
</w:sdtPr>

Notes

  • w:lock locking is enforced by authoring applications; it is not a security mechanism. A determined user or code can remove the lock attribute.
  • For stricter protection of entire document sections, use document protection (w:documentProtection in settings.xml).