1

I have a text file having words that i need to validate. After following the post : How can I use Microsoft Word's spelling/grammar checker programmatically?

I used the Microsoft word for spell check.But i am unable to get the improper words from the word api using doc.SpellingErrors.Item(1).Name(as there is no Name attribute available). So how can i retrieve words(in text) from the object returned by doc.SpellingErrors.

Community
  • 1
  • 1
Kratos85
  • 183
  • 2
  • 5

1 Answers1

2

Try something like this:

import win32com.client

word = win32com.client.Dispatch("Word.Application")
doc = word.Documents.Open(r"C:\temp\foo.doc")
if doc.SpellingErrors.Count:
    for err in doc.SpellingErrors:
        print err.Text
else:
    print "No errors"
word.Quit()
word = None
alan
  • 4,752
  • 21
  • 30