python-openxml / python-docx

Create and modify Word documents with Python
MIT License
4.38k stars 1.08k forks source link

Highlight particular word in python docx #1381

Closed ghost closed 2 months ago

ghost commented 2 months ago

I want to highlight the particular word in the paragraph of docx

Paragraph : English, with its twisty history and vast vocabulary, has become a global language. Borrowing words and morphing over centuries, it connects people across continents. though its rules can be tricky, English unlocks a world of literature, music, and ideas.

Here the font style are arial but word global has Times New Roman style Here the font size are 12 but the word over has 15

I want to split the paragraph by the word though and I want to highlight the word though

I have done highlight word but the thing is the word global is changed to arial and word over size is changed to 12

but I want that word to be in the same state word global as Times New Roman and word over size is 15

scanny commented 2 months ago

Check out this SO answer: https://stackoverflow.com/a/68507579/1902513