How can I do French and English Spell Checking using MS Word from Python

Pater Maximus emayo at home.com
Thu Oct 21 13:02:55 EDT 2004


I am a newbie to Python and do not understand COM so forgive the irrelevant
details encluded below:

Well I thought I had the problem solved, but it stopped working for both
Dispatch and EnsureDispatch. The code is:

import win32com.client
import msword9
#msword = win32com.client.Dispatch("Word.Application")
#msword.Selection.LanguageID=1033
msword = win32com.client.gencache.EnsureDispatch ("Word.Application")
msword.Selection.LanguageID = 1033

Here is what happened.
* I added German language spell checking to Word and started getting
AttributeError: 'NoneType' object has no attribute 'LanguageID'

* Since my source was unchanged, I figured I had better rebuild some stuff.
Ran makepy as follows

C:\Program Files\Microsoft Office\Office>"c:\program
files\python\lib\site-packages\win32com\client\makepy.pyc" msword9.olb >
"c:\program files\python\msword9.py"

Generating to
C:\PROGRA~1\PYTHON\lib\site-packages\win32com\gen_py\00020905-0000
-0000-C000-000000000046x0x8x1.py
that is 1445KB
It also produced
the .pyc version of the above with 1542KB
c:\program files\python\msword9.py with 0 bytes
c:\program files\python\msword9.pyc with 218 bytes

00020905-0000-0000-C000-000000000046x0x8x1.py has "Selection" defined and
"LanguageID" is a property but they are not being found. However, the
following command seems to find the library

>>> win32com.client.gencache.EnsureDispatch("Word.Application")
<win32com.gen_py.Microsoft Word 9.0 Object Library._Application instance at
0x9887256>

What am I doing wrong???

Thanks...







More information about the Python-list mailing list