[python-win32] read word contents including images and font format

Waldemar Osuch waldemar.osuch at gmail.com
Wed Oct 5 19:45:51 CEST 2011


On Wed, Oct 5, 2011 at 10:30, Tim Roberts <timr at probo.com> wrote:
> Anthony Mpofu wrote:
>>
>> I want to read contents from a word document (source) and insert the
>> contents to the (destination) word document.
>> ...
>> The above solution only copies the text content from the source document.
>> The read contents loses the original formating (font size, font type)
>> The read contents fails to load images from the document.
>>
>> Is there a method that will allow reading word content with the
>> original formatting as well as images.
>
> Do it exactly like you would do it by hand: go through the clipboard,
> using Copy and Paste methods.
>
Another option is to inject the source document into the destination using
"range.InsertFile"
It should preserve images and such.

I have used this approach recently to generate one document out bunch
of chunks stored in a database.

Waldemar


More information about the python-win32 mailing list