Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spellcheck Text Form Field

Status
Not open for further replies.

Tech2377

Programmer
Nov 13, 2007
81
I have 4 text form fields (and other form fields that don't matter) that I want spellchecked after leaving the field. The document is protected, so I know i have to unprotect it in my leave macro, although I don't know how to call the spellcheck function for the specific control I am leaving, and I don't want the "spellcheck is complete" window to appear unless there was a spelling error.
 
Hi Tech2377,

In Word 2003, this is a macro I've used to unprotect a form (fill in the appropriate password), spellcheck all fields. and then re-protect the form.


Code:
Sub FormsSpellCheck()

   ' If document is protected, Unprotect it.
   If ActiveDocument.ProtectionType <> wdNoProtection Then
      ActiveDocument.Unprotect Password:="password"
   End If

   ' Set the language for the document.
   Selection.WholeStory
   Selection.LanguageID = wdEnglishUS
   Selection.NoProofing = False

   ' Perform Spelling/Grammar check.
   If Options.CheckGrammarWithSpelling = True Then
      ActiveDocument.CheckGrammar
   Else
      ActiveDocument.CheckSpelling
   End If

   ' ReProtect the document.
   If ActiveDocument.ProtectionType = wdNoProtection Then
      ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
         NoReset:=True, Password:="password"
   End If

End Sub

HTH,



Best,
Blue Horizon [2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top