

Please note that you can of course download the template and the code by clicking on the link below ''' To perform the automatic writing, you can use the following code. Comments are inserted in the code to explain the purpose of each part of the code. The following python code lines can be used to perform the filling of the Word template automatically. Then insert the cross-reference, where you need it, as illustrated in the figures below:Ĭreate a (python) script to fill the templateĪs already stated, reading the data from the source is out of the scope of this article and will not be detailed. To do so, you need to create the bookmarks Associate bookmarks to the “rich text” object. You can also have some bookmarks, so that you can reuse the given information (names) for example, via cross-references. You could have a template in the following form, where the objects are named and tagged. In the template, you can give the rich text object a name and a tag, so that it can be found and identified.

I would suggest using “rich text” object. Filling automatically a Microsoft Word template using python Create a Microsoft Word template ready for automationĪctually, you need to use some objects in the Word template, which can be controlled from outside of Micosoft Word. This solution is composed by these three principal steps. The only thing you need is to re-write the proposed algorithm in the desired language -). Please notice that this solution can be written in any other language. The following solution is based on Python. If you have problems with this step, please let a comment, so that we can extend this article, if needed. This part should be resolved from you and the data should be available for the code. Here, we are assuming that the data are made available to the code, which use them to update the template automatically. Please note that the focus will not be made on the first step (Link to the database). Do you have Word templates, which need to be updated regularly from a certain source? Tired of doing this manually and want to automate the task, via python for example? Then this article is for you.
