0
Right now my program is reading a file and extracting words colored in red on that word document, but I want my program to be able to use all the files in a document instead, can someone please help me with this?

This is what I have, it is using a "filpath.docx", but I want it o use a folder instead with several word documents


import docx from docx.shared import RGBColor

def readtxt(filename):
    doc = docx.Document(filename)
    fullText = []
    for para in doc.paragraphs:
        for run in para.runs:
            if run.font.color.rgb == RGBColor(255, 000, 000):
                fullText.append(run.text)
    return fullText

fullText = readtxt('filepath.docx') 
William
  • 1
  • 3
  • Have a look at this: https://stackoverflow.com/questions/18262293/how-to-open-every-file-in-a-folder – Swifty Nov 05 '22 at 20:41

0 Answers0