Skip to content

Shapes in a for loop #325

Open
Open

Description

@PaulTerrasi

If the template document has a shape or text box in a for loop, whether it is inline or not, the rendered document will appear as corrupted. Word seems to be able to repair the document, and the shape is duplicated by the loop as expected once that happens.

I have only tested this on Word v16.42 for Mac OS, in case this happens to be specific to certain versions of Word.

Activity

  1. elapouya commented on Nov 16, 2020

    @elapouya
    Owner

    I think the reason is that for-loops create duplicate object IDs. There is no plan to renumber such objects in docxtpl. Tagging this issue as enhancement.

  2. cvas22 commented on Nov 25, 2026

    @cvas22

    @PaulTerrasi this is fixed in docform, the maintained fork of python-docx-template. Copies of a shape or text box made by a loop now get unique anchorId, VML shape id and o:spid values, which were the duplicates behind the repair prompt (cvas22/docform#209).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions