Skip to main content
Solved

Populate MS-Word Template Bookmarks/Content Controls with Attributes

  • April 7, 2022
  • 2 replies
  • 135 views

canerakin
Contributor
Forum|alt.badge.img+6

I've realized that we can include a template to MS-Word writer (docx). However it seems it only captures formatting from the template.

 

Is there any way that I can populate specific Bookmarks/Content Controls based on their title/tag names with attributes?

Best answer by debbiatsafe

Hi @canerakin​ 

The Microsoft Word writer does not have this functionality natively.

Since you are working with .docx files and this format is part of Open Office XML, it should be possible to unzip the .docx file and directly manipulate the XML files contained within the zip. The folders and files should be zipped afterwards.

I've included an example workspace of this method and I hope it helps.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

debbiatsafe
Safer
Forum|alt.badge.img+21
  • Safer
  • 648 replies
  • Best Answer
  • April 20, 2022

Hi @canerakin​ 

The Microsoft Word writer does not have this functionality natively.

Since you are working with .docx files and this format is part of Open Office XML, it should be possible to unzip the .docx file and directly manipulate the XML files contained within the zip. The folders and files should be zipped afterwards.

I've included an example workspace of this method and I hope it helps.


canerakin
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • 51 replies
  • April 21, 2022

Hi @canerakin​ 

The Microsoft Word writer does not have this functionality natively.

Since you are working with .docx files and this format is part of Open Office XML, it should be possible to unzip the .docx file and directly manipulate the XML files contained within the zip. The folders and files should be zipped afterwards.

I've included an example workspace of this method and I hope it helps.

Hi Debbie,

Thanks a lot for this example. I've actually prepared a python script with docxtpl library. However I feel like your example can be more sustainable in the long run. Appreciated!