code is poetry…

replacing bookmarks in a word document with python —

The last days I was fighting around with how to replace a bookmark in a word (docx) document.

After years of python programming I thought that this would be a simple task, helped by a python module. weeell emmm, I was wrong!

What I learned was that a word document is a simple zip-file, with a folder structure and a few xml-documents.

Here is a code which uncompresses the file, changes the defined bookmarks and recompresses it (in a new file) as a word document:



It’s all pretty basic, but it should help understanding the stupidness of microsoft!!!


Categorised as: codes | coding | python

Leave a Reply