COM and MS Word

logistix logistix at zworg.com
Mon Apr 7 09:28:48 EDT 2003


anthony.evershed at npl.co.uk (CTony) wrote in message news:<2eb85cfb.0304070115.6aecb644 at posting.google.com>...
> 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

Set Selection.Start and Selection.End manually.  Sorry I can't tell
you what to set them to (I think that'll be document specific)




More information about the Python-list mailing list