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

Roger Upole rupole at hotmail.com
Thu Oct 21 20:06:25 CEST 2004


If you don't have a document loaded into Word, Selection returns None.
    hth
       Roger

"Pater Maximus" <emayo at home.com> wrote in message
news:5O2dnbI66-z9c-rcRVn-gw at comcast.com...
> 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