ActiveDocument.Protect

I've developed a form with tables and form fields. Protection is controlled with the following code.

ActiveDocument.Protect Password:=MyPassword, NoReset:=True, Type:=wdAllowOnlyFormFields

Problem is, form fields can be replicated/duplicated through the use of the Enter key. That is, with a form field selected, pressing the Enter key adds a new line where it adds a duplicate form field.

Is it possible to prevent this functionality and still permit form field editing?

Thanks.

Answer
Answer

The Enter key isn't really creating a separate new field -- it's just that the Enter key creates a paragraph break within the field, and the new paragraph is separated from the previous one by the Space After setting of the current style.

Image

There are two issues here. One is that you don't want to allow new paragraphs inside a form field, and the other is that you probably don't want entries in a field to expand the depth of the table row and throw off the alignment of the form.

The first issue can be handled with some macros, which are given at http://support.microsoft.com/kb/211219. Although the article says it's applicable to Word 2000 and 2002, it's actually still valid all the way up to Word 2013 (currently).

The second issue is a bit touchier: If someone types in a long text, even without pressing Enter, the field will expand and push the rest of the table down. You can prevent the misalignment by going into the Table Properties dialog and setting the row height(s) to an Exact size. The user can still type more than will fit in the table cell, but the overflow will disappear below the bottom of the cell.

If the filled forms will be processed by macros, you may have to deal with overfilled fields, but that's another issue.

_____________________________
https://jay-freedman.info

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated March 30, 2025 Views 786 Applies to: