COM and MS Word

CTony anthony.evershed at
Mon Apr 7 11:15:31 CEST 2003

It appears that some data files I need are in WordPerfect (.dat)
format, and I need to get them into Python for processing and later
entry into a database. I haven't been able to find a way of
interfacing to WordPerfect directly, but MS Word 2000 can read these

Here's the snag, though. All the examples of Python/COM/Word usage
I've seen have involved pushing data into Word, rather than extracting
data *from* it. I know that the data field I need is x lines below a
known heading, so getting to the field is no problem:

finder = wd.Selection.Find
finder.Text = 'foo'
for n in range(x):

get you to the beginning of the field, no problems. How, however, can
I select (block mark) and extract that line of text?

If it helps, I'm using Python 2.2, with win32all build 148, on Windows
NT 4 (though the resulting program will be used on Windows 2000 as

Many thanks,

Tony Evershed

More information about the Python-list mailing list