|
-
Aug 27th, 2003, 12:51 PM
#1
Thread Starter
New Member
GetSpellingSuggestions in Word COM
I have a pretty neat piece of code running that uses Microsoft Word's COM to do spell checking. I am using the GetSpellingSuggestions method to let Word tell me what it thinks are good suggested changes for each misspelled word.
Here is the problem. I can't figure out an equivalent way to do Grammer. The function for finding out the grammer errors is easy, but I don't see a way to get Suggested Grammer changes. Does anyone have experience with this? Here is a sample piece of code:
Code:
Dim WordApp As New Word.Application
Dim SpellSuggestions As SpellingSuggestions
Dim SpellSuggest As SpellingSuggestion
Dim SpellDoc As New Word.Document
Dim SpellSentences As Word.Sentences
Dim lngCount1 As Long, lngCount2 As Long
Dim SpellRange As Word.Range
Dim SpellProofRead As Word.ProofreadingErrors
Set SpellDoc = WordApp.Documents.Add
SpellDoc.Content = m_SpellCheckText
WordApp.Options.CheckGrammarWithSpelling = True
Set SpellSentences = SpellDoc.Sentences
For lngCount1 = 1 To SpellSentences.Count
Set SpellRange = SpellSentences(lngCount1)
frmSpellCheck.txtSentence.Text = SpellRange
' Spelling Error Check
If SpellRange.SpellingErrors.Count > 0 Then
For lngCount2 = 1 To SpellRange.SpellingErrors.Count
frmSpellCheck.lstSuggestions.Clear
frmSpellCheck.txtWord.Text = SpellRange.SpellingErrors(lngCount2)
Set SpellSuggestions = SpellRange.SpellingErrors(lngCount2).GetSpellingSuggestions
For Each SpellSuggest In SpellSuggestions
frmSpellCheck.lstSuggestions.AddItem SpellSuggest.Name
Next
If frmSpellCheck.lstSuggestions.ListCount > 0 Then
frmSpellCheck.lstSuggestions.ListIndex = 0
frmSpellCheck.cmdChange.Enabled = True
Else
frmSpellCheck.lstSuggestions.AddItem "<No Suggestion>"
frmSpellCheck.cmdChange.Enabled = False
End If
Me.Show vbModal
If Me.m_booCancel Then GoTo Exit_Function
Next
End If
Though jumbled up, this code will use a spell checking window and show the users the misspelled word, and then give them suggestion to correct it. It gets these suggestions from WORD.
BUT, What I would also like to do is suggest grammer changes, and I simply can't find it. Any advice is appreciated. Thanks,
PS, if it helps, I know that you can use SpellRange.GrammaticalErrors.Count to get a count of Grammatical Errors.
You can also do this:
Code:
frmSpellCheck.txtWord.Text = SpellRange.GrammaticalErrors(lngCount2)
to see what the grammatical error is. But when you are using Microsoft Word directly, you can get the grammer suggestions as well. I want to tap into the object somehow but I don't where it is.
Thanks so much!
paul
Last edited by VanOverp; Aug 27th, 2003 at 12:55 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|