I am trying to automate word processing for multiple files using python
How to delete or manipulate text with a certain formatting and font(color, bold, italics etc..) from word using python?
This is a sample word file to make things more clearer.
**am trying to delete the red text and change the blue text to black again. **Sample text
This is the code I found in the internet to produce colored text. Hope this helps, am still trying to make code changes to the code snippet.
from docx import Document
from docx.shared import RGBColor
document = Document()
run = document.add_paragraph().add_run('My name is John')
font = run.font
font.color.rgb = RGBColor(0xFF, 0xFF, 0x0)
p=document.add_paragraph('aaa')
document.save('demo1.docx')
document.paragraphs[0].text
any suggestions would be very helpful
teepan karti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.