View Single Post
 
Old 07-02-2019, 01:59 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You need a macro stored in the document to unprotect the document, run the spell check then re-protect it again e.g.

Code:
Sub SpellCheckForm()
Dim i As Integer
Dim bProtected As Boolean
    'Unprotect the file
    If Not ActiveDocument.ProtectionType = wdNoProtection Then
        bProtected = True
        ActiveDocument.Unprotect Password:=""
    End If
    ActiveDocument.Range.NoProofing = True
    'check each formfield for spelling
    For i = 1 To ActiveDocument.FormFields.Count
        ActiveDocument.FormFields(i).Select
#If VBA6 Then
        Selection.NoProofing = False
#End If
        Selection.LanguageID = wdEnglishUK
        Selection.Range.CheckSpelling
    Next
    'Reprotect the document.
    If bProtected = True Then
        ActiveDocument.Protect _
                Type:=wdAllowOnlyFormFields, _
                NoReset:=True, _
                Password:=""
    End If
lbl_Exit:
    Exit Sub
End Sub
Alternatively you could create the document using content controls which don't require a macro to check the contents.

If you want to restrict editing to the controls then you would add 'Editors' to the controls and protect the form as read only which limits editing to the controls. The spell check will still work with the document protected.

You may find Insert Content Control Add-In useful for both inserting the controls and applying the editors.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote