I am using win32com to convert a .docx file into a .txt file. It works well until it gets unrecognized characters in Spanish.
DOC_FILEPATH = r"C:\Temp\Hugo- Ortíz -.docx"
s = find_between_r(DOC_FILEPATH, '.', '')
FILETXT = DOC_FILEPATH.strip(s)
FILETXT = FILETXT + "txt"
doc = win32com.client.GetObject(DOC_FILEPATH)
text = doc.Range().Text
with open(FILETXT, "wb") as f:
f.write(text.encode("utf-8"))
When win32com.client reads the DOC_FILEPATH, I get this error
moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname)
pywintypes.com_error: (-2147221014, 'El moniker no puede abrir un archivo', None, None)
Is there a way to read that file without changing the name?