Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 07-02-2019, 01:59 AM
gmayor's Avatar
gmayor gmayor is offline How can you run spell check on a protected document Windows 10 How can you run spell check on a protected document Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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 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
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can you run spell check on a protected document Spell Check stopped in middle of document bsuedmeyer Word 6 03-20-2016 10:06 AM
How can you run spell check on a protected document Spell Check is marking ALL words copied from downloaded document as mispelled silveringofrose Word 8 03-13-2016 09:23 AM
Protected Document (Form) that allows Spell Check beve56 Word 3 03-21-2014 06:15 PM
Spell check checking only part of document Adeyo Word 1 02-24-2013 10:49 PM
How can you run spell check on a protected document Spell check not working correctly in table of form document troybuell Word 1 07-23-2012 12:08 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:10 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft