mword2text on win32

Emile van Sebille emile at fenx.com
Thu Mar 7 09:39:39 EST 2002


Thomas Guettler
> Does someone know how I can convert
> msword to plain text in python on win32?
> 
> I tried wvware from gnuwin32.sf.net (with popen3)
> but it fails with complex documents.
> 

from win32com.client import Dispatch
word = Dispatch('Word.Application')
worddoc = word.Documents.Open(r'C:\testtext.doc')
ii = 1
while 1:
    try:
            nextparagraph = worddoc.Paragraphs(ii)
    except:
            break
    print nextparagraph
    ii += 1

HTH,

-- 

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list