D
D
Dmitry2017-05-11 15:14:21
JavaScript
Dmitry, 2017-05-11 15:14:21

How to automate the process of copying text from MS WORD to another document using python and arrange it in the right places (full name)?

In general, I want to make my life easier and get rid of the routine. on duty, they often bring a list of people who need to be presented for an award, those full names from one document must be reprinted into another, and since these people are dofiga and laziness is the engine of progress, I want to know how to implement this where to watch what to read? links to the material are welcome and preferably in Russian

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2018-07-12
@hujak_hujak

My elementary function does not work ((
Because you are trying to bind a handler to a collection of elements, but this is not supported.
and so too
Not true.

T
TomasHuk, 2017-05-12
@ipatov_dn

Use the docxtpl library .
Algorithm:
1. First, purely for convenience, make a txt file with a list of full names (it is convenient to read the file into a python list).
2. Create a word template with tags in the form of {{ }} at the insertion point.
3. Loop through the list with full name and generate a docx file based on the template. In the generated document, the tags will be replaced with the desired values.
Example from docxtpl documentation :

from docxtpl import DocxTemplate

doc = DocxTemplate("my_word_template.docx")
context = { 'company_name' : "World company" }
doc.render(context)
doc.save("generated_doc.docx")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question