I built a script who modify some word in a imported word file .
from docx import Document
document = Document('filename.docx')
paragraphs = document.paragraphs
dic = {'XxwordxX': modifiedword}
for p in document.paragraphs:
for key in dic.keys():
if key in p.text:
p.text = p.text.replace(key,dic[key])
document.save('new.docx')
Unfortunately, the paragraph where the word has be modified isn't bold anymore (it was bold in filename).
And I cannot found how to bold it again.
I tried this :
from docx import Document
document = Document('filename.docx')
paragraphs = document.paragraphs
dic = {'XxwordxX': modifiedword}
for p in document.paragraphs:
for key in dic.keys():
if key in p.text:
p.text = p.text.replace(key,dic[key])
para = document.paragraphs[2]
run.bold = True
document.save('new.docx')
But even though I haven't any error, the paragraph isn't bold in the output.
Any ideas how to do that ? The only tips I found on internet are for bold paragraph added manually.