Accessing Microsoft Word from Python

  • Thread starter =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=
  • Start date
?

=?ISO-8859-1?Q?Mickel_Gr=F6nroos?=

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
 
J

Josiah Carlson

Mickel said:
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,

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
 
R

Rene Pijlman

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

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

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

John J. Lee

Rene Pijlman said:
Mickel Grönroos:

This book: http://safari.oreilly.com/1565926218 explains how to access
Excel from Python. It also explains COM-interfacing in general.
[...]

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
 
J

John J. Lee

Josiah Carlson said:
Mickel said:
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
[...]
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.

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


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top