How Do I Embed A Csv File Into A Word Document With Python Docx
I'm opening a docx file and I want to embed into it a csv file. The csv should be displayed as an icon. How would I set it's ecaxt position in my Word File? My code so far is: from
Solution 1:
I was able to embed the csv using pywin32 library.
import win32com.client as win32
.
.
.
word = win32.gencache.EnsureDispatch('Word.Application')
doc=word.Documents.Open(doc_path)
word.Visible = False
.
.
.
doc.InlineShapes.AddOLEObject(FileName=doc_path3,DisplayAsIcon=1,Range=range1,IconLabel="CSV",IconFileName=doc_path4)
word.ActiveDocument.SaveAs(doc_path2)
doc.Close()
Post a Comment for "How Do I Embed A Csv File Into A Word Document With Python Docx"