Connecting Tech Pros Worldwide Help | Site Map

Accessing Microsoft Word from Python

Mickel Grönroos
Guest
 
Posts: n/a
#1: Jul 18 '05
Hi!

I'm fiddling with Python for Windows (normally using Linux) and as a part
of that I want to try to make a simple word frequency list generator to be
used in conjunction with Microsoft Word. Does anybody have any good
pointers on where I can find information about accessing Word-documents
(or other Microsoft Office applications) from Python? To be more specific,
I want to be able to:

- get the text content of the full Word document
- define a callback in Python that is called every time a user enters a
character into the text of a Word document
- get the last two graphical word tokens before the current position of
the insertion cursor in the text of the Word document.

Cheers!

/Mickel

--
Mickel Grönroos, application specialist, linguistics, Research support,CSC
PL 405 (Tekniikantie 15 a D), 02101 Espoo, Finland, phone +358-9-4572237
CSC is the Finnish IT center for science, www.csc.fi

Josiah Carlson
Guest
 
Posts: n/a
#2: Jul 18 '05

re: Accessing Microsoft Word from Python


Mickel Grönroos wrote:[color=blue]
> Hi!
>
> I'm fiddling with Python for Windows (normally using Linux) and as a part
> of that I want to try to make a simple word frequency list generator to be
> used in conjunction with Microsoft Word. Does anybody have any good
> pointers on where I can find information about accessing Word-documents
> (or other Microsoft Office applications) from Python? To be more specific,
> I want to be able to:
>
> - get the text content of the full Word document
> - define a callback in Python that is called every time a user enters a
> character into the text of a Word document
> - get the last two graphical word tokens before the current position of
> the insertion cursor in the text of the Word document.
>
> Cheers!
>
> /Mickel[/color]

Mickel,

Sounds like something that could be done with VB. VB will let you
script anything in Word or Office, but then it requires you to learn the
horror that is VB. Perhaps a limited interface is available through
COM, but I wouldn't bet the farm on it.

- Josiah
Rene Pijlman
Guest
 
Posts: n/a
#3: Jul 18 '05

re: Accessing Microsoft Word from Python


Mickel Grönroos:[color=blue]
>Does anybody have any good pointers on where I can find information
>about accessing Word-documents (or other Microsoft Office applications)
>from Python?[/color]

This book: http://safari.oreilly.com/1565926218 explains how to access
Excel from Python. It also explains COM-interfacing in general.
[color=blue]
>To be more specific, I want to be able to:[/color]

I think you should look that up in the Word object model (probably on
http://msdn.microsoft.com), since it's not Python-specific.

--
René Pijlman
John J. Lee
Guest
 
Posts: n/a
#4: Jul 18 '05

re: Accessing Microsoft Word from Python


Rene Pijlman <reply.in.the.newsgroup@my.address.is.invalid> writes:
[color=blue]
> Mickel Grönroos:[color=green]
> >Does anybody have any good pointers on where I can find information
> >about accessing Word-documents (or other Microsoft Office applications)
> >from Python?[/color]
>
> This book: http://safari.oreilly.com/1565926218 explains how to access
> Excel from Python. It also explains COM-interfacing in general.[/color]
[...]

O'Reilly used to have a book on Word's object model by Steven Roman.
Haven't read it, and I don't know if it's still published/up-to-date,
but I know Roman's book on MS Access is good (haven't looked, but I
guess the ref you give above is another book by the same author).


John
John J. Lee
Guest
 
Posts: n/a
#5: Jul 18 '05

re: Accessing Microsoft Word from Python


Josiah Carlson <jcarlson@nospam.uci.edu> writes:
[color=blue]
> Mickel Grönroos wrote:[color=green]
> > Hi!
> > I'm fiddling with Python for Windows (normally using Linux) and as a
> > part
> > of that I want to try to make a simple word frequency list generator to be
> > used in conjunction with Microsoft Word. Does anybody have any good[/color][/color]
[...][color=blue]
> Sounds like something that could be done with VB. VB will let you
> script anything in Word or Office, but then it requires you to learn
> the horror that is VB. Perhaps a limited interface is available
> through COM, but I wouldn't bet the farm on it.[/color]

I think the entire thing is exported through COM, and VB uses that.


John
Closed Thread