I try to convert *.doc to *.txt and in saving part of my script I 
receive following error.
Can anyone help - I have tried all I know without any success. I could 
swear it worked at win98. Now i do not have chnage to run it there - I 
have w2000, office2000, py2.4

-------------------------------------------------------------
processing i:\Škola\Archiv\Archiv 8zs\Fyzika\F8 0-A.doc -->
Traceback (most recent call last):
  File "I:\Python\my_py\J5804173.py", line 58, in ?
    wordapp.ActiveDocument.SaveAs(docastxt, 
FileFormat=win32com.client.constants.wdFormatText)
  File "C:\prg\Python24\Lib\site-packages\win32com\client\__init__.py", 
line 168, in __getattr__
    raise AttributeError, a
AttributeError: wdFormatText
--------------------------------------------------------

my script:
--------------------------------------------------------------------------
import fnmatch, os, win32com.client, time

inDir=ur'i:\Škola\Archiv\Archiv 8zs\Fyzika'
outDir=u'i:\\text\\'

wordapp = win32com.client.Dispatch("Word.Application")
if not os.path.isdir(outDir): os.makedirs(outDir)
for path, dirs, files in os.walk(inDir):
    docFiles=  [os.path.abspath(os.path.join(path, filename)) for 
filename in files \
                if (fnmatch.fnmatch(filename, '*.doc') and not 
fnmatch.fnmatch(filename,'~*.doc'))]
    for doc in docFiles:
        print "processing %s -->" % doc,
        wordapp.Documents.Open(doc)
        soubor=os.path.basename(doc.rstrip('.doc').rstrip('.DOC'))
        docastxt = outDir+soubor + u'.text'
        wordapp.ActiveDocument.SaveAs(docastxt, 
FileFormat=win32com.client.constants.wdFormatText)
        wordapp.ActiveDocument.Close()
        print docastxt
-----------------------------------------------------------------------


When I create macro in Word, I can see there this "wdFormatText" and 
even in some tutorial I saw in used in this way...

Thanks a lot

-- 
geon


_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to