Spell check only form fields on a protected document

Ease of Use


Version tested with

97, 2000, 2002, 2003 

Submitted by:



Two methods to enable the spell checker on Formfields. One for each individual field, (Needs to be atttached to each formfield) and one that will spell check all formfields. (Needs to be attached to the last formfield) 


Ok, say someone wants you to make a template for them with a bunch of form fields on it and it really won't require code because they are just filling in their info. The owner of the form wants the end user to be able to spell check the information that they put into it. But they don't want them to be able to change anything else in the form. If you protect the form then the spellcheck feature is not available. So this is a fast and super easy way to do this without much code involved. 


instructions for use


Option Explicit Sub myCheckSpelling() MsgBox "Demo one field spell check" 'Select Paragraph ActiveDocument.Bookmarks("\Para").Select With Selection #If VBA6 Then 'Only Word > 2000 .NoProofing = False #End If 'Set language .LanguageID = wdEnglishUS 'Run spell checker .Range.CheckSpelling End With End Sub 'This is the code to use if you want this to run on exit from the last field on 'the form/template. ' Thanks to MOS Master and fumei for their help with this one Sub myTotalCheckSpelling() Dim iCnt As Integer With Application.ActiveDocument 'Unprotect if protected If .ProtectionType <> wdNoProtection Then _ .Unprotect Password:="" 'Loop all formfields For iCnt = 1 To .FormFields.Count 'Select formfield .FormFields(iCnt).Select #If VBA6 Then 'Only Word > 2000 Selection.NoProofing = False #End If 'Set Language Selection.LanguageID = wdEnglishUK 'Run spell checker Selection.Range.CheckSpelling Next 'Reprotect without resetting the fields .Protect Type:=wdAllowOnlyFormFields, Noreset:=True, Password:="" MsgBox "Demo all fields spell check completed", vbInformation End With End Sub

How to use:

  1. Choose the code for the option that you want - either assign it to every form field or just the last field and copy it.
  2. Open the document.
  3. Press Alt + F11 to open the Visual Basic Editor (VBE).
  4. From the Menu, choose Insert-Module.
  5. Paste the code into the right-hand code window.
  6. Close the VBE, save the file if desired.
  7. Insert a text form field. Place your cursor in your document wherever you would like the form field to be.
  8. From the Forms toolbar click the Text Form Field button and the field is inserted for you.
  9. Right-click the field that was just inserted and click Properties.
  10. In the Run a macro: section of the dialog box, click the drop down arrow in the Exit box.
  11. Choose your macro
  12. Do this for each field you create or for just the last field in the document.
  13. Save your document as template.

Test the code:

  1. Open Word and choose File ... New
  2. Click either General Templates or On my computer (depending on your version of Word)
  3. Choose your template
  4. Type in one of the form fields (making sure to make and error) and press the Tab key.
  5. The SpellCheck dialog box should come up and give you suggestions.

Sample File:

Spell Check on exit.zip 14.29KB 

Approved by mdmackillop

This entry has been viewed 109 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express