anchor_locked property

ShapeBase.anchor_locked property

Specifies whether the shape’s anchor is locked.

@property
def anchor_locked(self) -> bool:
    ...

@anchor_locked.setter
def anchor_locked(self, value: bool):
    ...

Remarks

The default value is False.

Has effect only for top level shapes.

This property affects behavior of the shape’s anchor in Microsoft Word. When the anchor is not locked, moving the shape in Microsoft Word can move the shape’s anchor too.

Examples

Shows how to lock or unlock a shape’s paragraph anchor.

doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
builder.writeln('Hello world!')
builder.write('Our shape will have an anchor attached to this paragraph.')
shape = builder.insert_shape(shape_type=aw.drawing.ShapeType.RECTANGLE, width=200, height=160)
shape.wrap_type = aw.drawing.WrapType.NONE
builder.insert_break(aw.BreakType.PARAGRAPH_BREAK)
builder.writeln('Hello again!')
# Set the "AnchorLocked" property to "true" to prevent the shape's anchor
# from moving when moving the shape in Microsoft Word.
# Set the "AnchorLocked" property to "false" to allow any movement of the shape
# to also move its anchor to any other paragraph that the shape ends up close to.
shape.anchor_locked = anchor_locked
# If the shape does not have a visible anchor symbol to its left,
# we will need to enable visible anchors via "Options" -> "Display" -> "Object Anchors".
doc.save(file_name=ARTIFACTS_DIR + 'Shape.AnchorLocked.docx')

See Also