Microsoft Word - CheckGrammar when used on FormField only checks grammar and not spelling

Asked By John Wirth on 27-Jun-13 05:24 AM
Am using code to check the grammar and spelling of text in a formfield. Range.CheckGrammar should check both spelling and grammar, but it only checks the grammar and ignores spelling mistakes. If I use Range.CheckSpelling then it checks just the spelling. If I paste the text into the document and run spell check then it checks both spelling and grammar.
If I use
It checks one and then the other, but I do not want that and want it to run in on go as it normally does, checking both at the same time.

Sub FFSpellCheck()
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=""
End If
ActiveDocument.FormFields("TextBox2").Range.LanguageID = wdEnglishUK
ActiveDocument.FormFields("TextBox2").Range.NoProofing = False
Options.CheckGrammarWithSpelling = True
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
End If
End Sub
Robbe Morris replied to John Wirth on 29-Jun-13 05:11 PM
Turn on the macro recorder in Microsoft Word.  Then perform the steps you want to occur manually.  Upon completion, look at the VBA code the macro recorder generated.  Take that code and customize to fit your needs.
John Wirth replied to Robbe Morris on 02-Jul-13 02:30 AM
Thanks Robbe, I tried that, and found this method works:
Application.DisplayAlerts = False
Selection.GoTo What:=wdGoToBookmark, Name:="Text1"
With ActiveDocument.Bookmarks
        .DefaultSorting = wdSortByName
        .ShowHidden = False
End With
Selection.LanguageID = wdEnglishUK
Selection.NoProofing = False
Application.CheckLanguage = True
If Options.CheckGrammarWithSpelling = True Then
End If
Application.DisplayAlerts = True

It seems to be the line ActiveDocument.CheckSpelling that is required. As I only want one particular form field checked, turning off display alerts stops the prompt for checking the rest of the document. Oddly, if I change that to Selection.Range.CheckSpelling it ONLY checks the grammar. Not sure why, but at least I have a solution.