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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to Spellcheck a protected form

Status
Not open for further replies.

LWinfrey

Technical User
Jan 18, 2000
16
US
I have recently begun creating forms for a law firm and have noticed that when completing a form, the attorneys are unable to spellcheck their comments/answers. The only way I've been able to get around this is to unlock the document. Is there any other way to execute the Spellcheck function?
 
Unfortunately, the solution is not pretty. This is from a post here last week:<br>
<br>
SUMMARY<br>
This article describes methods that allow you to: <br>
<br>
Retain information you type into a form field when you protect a form.<br>
<br>
<br>
Unprotect a forms document, perform a spell check, and retain information in the form fields when you reprotect the form.<br>
<br>
<br>
<br>
<br>
<br>
MORE INFORMATION<br>
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web: <br>
<br>
<A HREF=" TARGET="_new">Method 1: Alter the Protect/Unprotect Command Functionality<br>
The following Microsoft Visual Basic for Applications macros (Sub procedures) protect your form without causing you to lose the text that you entered into a form field. The macros can be stored in the actual form template to allow you to manually unprotect and reprotect the form while preserving the form field contents. <br>
<br>
The following three macros can be used to ensure that your form field values are not reset to their defaults when you reprotect the form. <br>
<br>
<br>
The first macro runs when you click the Protect Form button on the Forms toolbar. <br>
<br>
<br>
The second macro runs when you click either Protect Document or Unprotect Document on the Tools menu. <br>
<br>
<br>
The third macro allows you to specify which sections to protect while maintaining previous form field values. <br>
<br>
<br>
NOTE: The name of this macro must be ProtectForm. <br>
Sub ProtectForm()<br>
<br>
' ******************************************<br>
' ProtectForm Macro.<br>
' Toggles protection for the active document<br>
' when the Protect Form button on the forms<br>
' toolbar is clicked.<br>
' ******************************************<br>
If ActiveDocument.ProtectionType = wdNoProtection Then<br>
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True<br>
Else<br>
ActiveDocument.Unprotect Password:=&quot;&quot;<br>
End If<br>
<br>
End Sub <br>
The following sample Visual Basic macro protects the active document without displaying the Protect dialog box. When you run this macro, it will reprotect the active document while maintaining previous form field values. <br>
<br>
NOTE: The name of this macro must be ToolsProtectUnprotectDocument. <br>
Sub ToolsProtectUnprotectDocument()<br>
<br>
' ******************************************<br>
' ToolsProtectUnprotectDocument Macro<br>
' Sets protection for the active document<br>
' when Protect Document or Unprotect Document<br>
' is clicked on Tools menu<br>
' ******************************************<br>
If ActiveDocument.ProtectionType = wdNoProtection Then<br>
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True<br>
Else<br>
ActiveDocument.Unprotect Password:=&quot;&quot;<br>
End If<br>
<br>
End Sub <br>
The following sample Visual Basic macro allows you to specify which sections to protect while maintaining previous form field values. You can assign this macro to a toolbar button or menu. <br>
Sub ProtectNoReset()<br>
<br>
Dim pDoc As Dialog<br>
Dim x As Integer<br>
On Error GoTo ProtectNoResetErr<br>
<br>
' If the document is protected,<br>
If ActiveDocument.ProtectionType &lt;&gt; wdNoProtection Then<br>
<br>
' Unprotect the document.<br>
ActiveDocument.Unprotect<br>
<br>
End If<br>
<br>
' Display the Protect Dialog box.<br>
Set pDoc = Dialogs(wdDialogToolsProtectDocument)<br>
x = pDoc.Display<br>
<br>
' If Cancel was chosen, exit this procedure.<br>
If x = 0 Then Exit Sub<br>
<br>
' Protect the document.<br>
ActiveDocument.Protect Password:=pDoc.DocumentPassword, _<br>
NoReset:=True, Type:=2<br>
<br>
ProtectNoResetErr: 'NOTE: This line MUST be left aligned.<br>
If Err &lt;&gt; 0 Then MsgBox Err.Description<br>
<br>
End Sub <br>
Method 2: Create a Macro to Protect/Unprotect Your Document<br>
The following examples protect the active document for forms without resetting the contents of the form fields. Create the macro and assign the macro to a key, menu, or toolbar button for easy access. <br>
If ActiveDocument.ProtectionType = wdNoProtection Then<br>
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True<br>
End If <br>
Method 3: Unprotect, Check Spelling or Update a Field, Reprotect a Document<br>
Because form field text is formatted for No Proofing, you can use the following macro to: <br>
<br>
<br>
Temporarily Unprotect the form. <br>
<br>
<br>
Change the language of the form fields. <br>
<br>
<br>
Perform a spell check or update a field. <br>
<br>
<br>
Reprotect the form while preserving the text you've typed into the form fields. <br>
<br>
<br>
You can use this macro as an On Exit macro for the last form field so you can check the spelling or update a field before you save the form. <br>
Sub FormsSpellCheck()<br>
<br>
' If document is protected, Unprotect it.<br>
If ActiveDocument.ProtectionType &lt;&gt; wdNoProtection Then<br>
ActiveDocument.Unprotect Password:=&quot;&quot;<br>
End If<br>
<br>
' Set the language for the document.<br>
Selection.WholeStory<br>
Selection.LanguageID = wdEnglishUS<br>
<br>
' Perform Spelling/Grammar check.<br>
If Options.CheckGrammarWithSpelling = True Then<br>
ActiveDocument.CheckGrammar<br>
Else<br>
ActiveDocument.CheckSpelling<br>
End If<br>
<br>
' ReProtect the document.<br>
If ActiveDocument.ProtectionType = wdNoProtection Then<br>
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True<br>
End If<br>
<br>
End Sub <br>
<br>
 
Thank you so much BarryG! (for answering both my questions!!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top