开发者

How to get the indexes of a mistake in Word's GrammarErrors object

开发者 https://www.devze.com 2023-03-02 23:20 出处:网络
We\'re trying to use Word\'s COM objects in order to programatically get the spelling and grammar errors in some sentences. We\'re using code that looks something like this:

We're trying to use Word's COM objects in order to programatically get the spelling and grammar errors in some sentences. We're using code that looks something like this:

foreach (Word.Range range in this.GrammaticalErrors)
  {
    MessageBox.Show(String.Format(
      "Grammatical error: {0}",
      range.Text));
  }

  foreach (Word.Range range in this.SpellingErrors)
  {
    MessageBox.Show(String.Format(
 开发者_如何学Go     "Spelling error: {0}",
      range.Text));
  }

This works fine for spelling: We print the words that are mistaken. But for grammar, the object seems to return the text of the entire sentence.

Any idea how to get the specific words with a grammar error?

0

精彩评论

暂无评论...
验证码 换一张
取 消