How can I get the text by color from a word document with win32com?
问题 I have a word document with several tables. In each table there are two colors, black and red. I'd like to get the text from cells in a word document table by its color. I found a way, but I think it's very inefficient. The following code gets the text from a word table cell, and prints each word with it's color. import os, sys import win32com.client, re path = os.path.join(os.getcwd(),"../files/tests2.docx") word = win32com.client.Dispatch("Word.Application") word.Visible = 1 doc=word