GrammaticalErrors

A

Andrew

Hi,
I hope that someone can help with this.

I'm trying to write a macro that iterates through a list of grammatical errors in a document and produces a summary of the number of types of grammatical errors. I can get the ProofreadingErrors collection easily and iterate it, but all I seem to be able to access is the actual text that contains an error, not the grammar rule it failed. Given that the grammar check dialog will show the rule, I'm hoping that someone can point me towards a way of extracting this info directly from the ProofreadingErrors collection.

Cheers,

Andrew
 
J

Jean-Guy Marcil

Andrew was telling us:
Andrew nous racontait que :
Hi,
I hope that someone can help with this.

I'm trying to write a macro that iterates through a list of
grammatical errors in a document and produces a summary of the number
of types of grammatical errors. I can get the ProofreadingErrors
collection easily and iterate it, but all I seem to be able to access
is the actual text that contains an error, not the grammar rule it
failed. Given that the grammar check dialog will show the rule, I'm
hoping that someone can point me towards a way of extracting this
info directly from the ProofreadingErrors collection.

I do not think you can access grammar suggestions as you can for spelling
ones, for example:

'_______________________________________
Dim TestRange As Range
Dim myErrors As ProofreadingErrors
Dim sugList As SpellingSuggestions
Dim sug As SpellingSuggestion
Dim strSugList As String
Dim errText As String
Dim i As Long

Set TestRange = ActiveDocument.Paragraphs(1).Range

Set myErrors = TestRange.SpellingErrors
For Each myerr In myErrors
With myerr
errText = .Text
MsgBox errText
Set sugList = GetSpellingSuggestions(Word:=errText, _
SuggestionMode:=wdSpellword)
MsgBox sugList.Count
For Each sug In sugList
strSugList = strSugList & vbTab & sug.Name & vbLf
Next
MsgBox "The suggestions for this word are: " _
& vbLf & strSugList
End With
Next myerr
'_______________________________________

Will list all available suggestion for all spelling errors in the first
paragraph.
There are no equivalent methods/properties that I can find for the
GrammarErrors collection...

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
[email protected]
Word MVP site: http://www.word.mvps.org
 
A

Andrew

Jean-Guy Marcil said:
Andrew was telling us:
Andrew nous racontait que :


I do not think you can access grammar suggestions as you can for spelling
ones, for example:

Will list all available suggestion for all spelling errors in the first
paragraph.
There are no equivalent methods/properties that I can find for the
GrammarErrors collection...

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
[email protected]
Word MVP site: http://www.word.mvps.org
Thanks - I was aware of getting a list of spelling suggestions and don't need the suggested corrections for the grammar checker, rather, I need the title or text of the rule that was broken (eg: "fragment, consider revising...").

Is there anything undocumented as I, too, cannot find any method in the published documentation that would help.

Cheers,
Andrew
 
J

Jean-Guy Marcil

Andrew was telling us:
Andrew nous racontait que :
Is there anything undocumented as I, too, cannot find any method in
the published documentation that would help.

As far as I am aware, I do not think so. I have never seen code that does
that and googling in the VBA groups did not turn up anything....
Maybe someone knows a secret formula?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
[email protected]
Word MVP site: http://www.word.mvps.org
 
Top