WD: Form Fields Lose Text When Protected for FormsLast reviewed: March 6, 1998Article ID: Q119698 |
The information in this article applies to:
SUMMARYThis article describes methods that allow you to:
- Retain information you type into a form field when you protect a form. - Unprotect a forms document, perform a spell check, and retain information in the form fields when you reprotect the form. MORE INFORMATIONMicrosoft 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 engineers 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:
http://www.microsoft.com/supportnet/refguide/ Method 1: Alter the Protect/Unprotect Command FunctionalityThe following macros protect your form without causing you to lose the text that you entered into a form field. The macro can be stored in the actual form template, to allow you to manually unprotect and reprotect the form while preserving the form field contents. If you name this macro "ToolsProtectDocument," then when you click on Protect Document on the Tools menu to protect your document for forms, the created macro will run instead of Word's built-in command of the same name.
Sub MAIN Dim Dlg As ToolsProtectDocument Dlg.NoReset = 1 n = Dialog(dlg) If n = - 1 Then ToolsProtectDocument Dlg End Sub Method 2: Create a Macro to Protect/Unprotect Your DocumentThe following example protects 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.
ToolsProtectDocument .Type = 2, .NoReset = 1 Method 3: Unprotect, Check Spelling or Update a Field, Reprotect a DocumentIn Word 7.x and later, the form field text is formatted for No Proofing. Use the following macro to temporarily Unprotect the form, change the language of the form fields, perform a spell check or update a field, and reprotect the form while preserving the text you've typed into the form fields. You can use this macro as an On Exit macro for the last form field so that you can check the spelling or update a field before you save the form. Word 7.x:
Sub MAIN ' Prevents cancellation of the macro. DisableInput ' Unprotects the form. ' Note: include .DocumentPassword argument for password ' protected form. ToolsUnprotectDocument ' Select body of document. EditSelectAll ' Set language. Language "English (US)" ' Go to start of document. StartOfDocument ' Perform the spell check ToolsSpelling ' Reprotect the document for forms without resetting fields. ' Note: include .DocumentPassword argument for password ' protected form. ToolsProtectDocument .NoReset = 1, .Type = 2 End SubWord 6.x:
Sub MAIN ' Prevents cancellation of the macro. DisableInput ' Unprotects the form. ' Note: include .DocumentPassword argument for password ' protected form. ToolsUnprotectDocument ' Moves insertion point to top of document. StartOfDocument ' Starts Spell Checker. ToolsSpelling ' Reprotect the document for forms without resetting fields. ' Note: include .DocumentPassword argument for password ' protected form. ToolsProtectDocument .NoReset = 1, .Type = 2 End SubFor additional information, please see the following articles in the Microsoft Knowledge Base:
ARTICLE-ID: Q110174 TITLE : Preserving Text When Re-protecting a Form Without Macros ARTICLE-ID: Q109757 TITLE : WordBasic Examples: ToolsUnprotectDocument REFERENCES"Microsoft Word User's Guide," version 6.0, pages 305-26 "Microsoft Word Developer's Kit," version 6.0, pages 783-785
|
Additional query words: form field forms protect Unprotect lose lost text
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |