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

Tim Golden tim.golden at viacom-outdoor.co.uk
Fri Oct 22 04:54:18 EDT 2004


[Pater Maximus]

| Well I thought I had the problem solved, but it stopped 
| working for both Dispatch and EnsureDispatch. 

Just to clarify something here: once you've run EnsureDispatch
at least once, both Dispatch and EnsureDispatch do the same
thing. All that EnsureDispatch does is to make sure that a
proxy module has been generated.

| 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

I'm not sure what that "import msword9" is doing there. Is it
a module of your own? At any rate, you're not using it in this
code snippet.

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

Roger Upole said in another thread that an empty Word application
has no Selection object. That may well be true, but the following
code works perfectly for me, whether because it *isn't* true, or because
Word is automatically giving you at least one Document to work with.
In either case, it doesn't seem to be your problem.

<code>
import win32com.client

msword = win32com.client.gencache.EnsureDispatch ("Word.Application")
const = win32com.client.constants
msword.Selection.LanguageID = const.wdGerman

</code>

[... snip description of rebuilding ...]

This shouldn't have made any difference (altho' there's no
harm in it, just in case something had corrupted or become
misplaced).

Do you think you could post an *exact* dump of your interpreter
window, showing enough steps for the app to fail, and showing
the error message you receive?

Thanks
TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list