COM and MS Word

Patrick Vrijlandt patrick.vrijlandt at
Tue Apr 8 22:34:57 CEST 2003

Did you try to record a macro while you were doing manually once what you
plan to do?
Then of course, all you would do is change VB to Py ...

Patrick Vrijlandt

"CTony" <anthony.evershed at> schreef in bericht
news:2eb85cfb.0304070115.6aecb644 at
> 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
> files...
> 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'
> finder.Execute()
> for n in range(x):
>     wd.Selection.MoveDown
> wd.Selection.HomeKey
> 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
> well)...
> Many thanks,
> Tony Evershed

More information about the Python-list mailing list