Lavrton
Lavrton

Reputation: 1

How to save pictures to document with Python win32com

I am making html to doc converter

from win32com.client import Dispatch
wrd=Dispatch('Word.Application')
doc=wrd.Documents.Open(inputfile)
doc.SaveAs(outputfile, FileFormat=0)
doc.Close

And I wand save picture to document: Prepare->Edit links to file->Save picture to document

What command I need?

https://i.sstatic.net/SJOS7.png

Upvotes: 0

Views: 2569

Answers (1)

Mark
Mark

Reputation: 108522

I believe you are looking for the AddPicture method in the InlineShapes collection.

FileName

Required String. The path and file name of the picture.

LinkToFile

Optional Object. True to link the picture to the file from which it was created. False to make the picture an independent copy of the file. The default value is False.

**SaveWithDocument**

Optional Object. True to save the linked picture with the document. The default value is False.

Range

Optional Object. The location where the picture will be placed in the text. If the range isn't collapsed, the picture replaces the range; otherwise, the picture is inserted. If this argument is omitted, the picture is placed automatically.

Upvotes: 1

Related Questions