Using Forms

R

Ray Dunn

How can I limit users from entering a new line in a form field? I have
limited the number of charaters, but after protection is applied the user
can still hit the enter key. I don't want to ruin the spacing on the page.
Thanks,
Ray
ps. Word 2003, win xp pro
 
S

Suzanne S. Barnhill

Put the form field in a table cell with Exact row height. They'll still be
able to press Enter, but what they type will disappear. That's enough of a
clue for most users; if not, see “WD: How to Code ENTER Key to Move to Next
Field in Form” at http://support.microsoft.com?kbid=211219
 
R

Ray Dunn

Thanks Suzanne, but I do not want them to be able to enter a new line at
all. The progammable macro doesn't seem like it will work, due to the fact
that the form will be protected. The form must be protected. Any other
ideas?

Thanks again,
Ray
 
J

Jay Freedman

Hi Ray,

The macro *will* work -- it was developed specifically for use in protected
forms. However, it does assume that users are filling out the form on a
computer that has both the template (which must be unprotected) and the form
document based on the template. If you're sending the form through email,
this assumption is almost certainly false.

The method of setting an exact row height will prevent "ruining the
spacing", if that's your only concern. The only time I'd worry about
newlines with this method is when the field contents will be transferred to
a database, or otherwise used in a context where the additional material
would show up.

There are no other alternatives that I'm aware of, unless you and all your
form recipients are using Word 2003.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
R

Ray Dunn

Jay,
Here is what I have. I am a high school teacher and I am having
students fill out information about themselves on a form that I have
created. I have 20 computers in my lab and a server. I do not want to
place the form on each computer, if I can help it. I planned on placing the
form on the server, where the student only has read rights. Once they type
their information, they print it and hand it in. There would be no
template, just the protected document in a read-only folder on the server.
Any ideas, will the macros still work?
Thanks,
Ray
 
J

Jay Freedman

Yes, I believe it will work, with one small change.

The macros run when the template is used to create or open any document
based on that template, regardless of where the template's file is stored.

The change is needed because the template is in a read-only folder, so you
can't save it. The next-to-last line of the fourth macro should change from

Templates(1).Save

to

Templates(1).Saved = True

This "lies" to Word and tells it that there hasn't been any change in the
template, so it won't attempt to save it or prompt for a save.

Can you set up the template on the server and do a trial run on one or two
workstations before the term starts? That will either prove that it works or
show where the problem (if any) is. If you get an error message when you try
to close the form, remove the fourth macro from the template completely;
then you'll have to restart Word to restore the original function of the
Enter key.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
R

Ray Dunn

I don't seem to be having much luck. Do the macros supposed to run
automatically? All of the vba code has been entered and I have set my
security to low, but when I open the file I get "Sub or Function not
defined"

Ray
 
J

Jay Freedman

The answer to this problem is in the article
(http://support.microsoft.com/?kbid=211219) that contains the macros:

"IMPORTANT: For this code to work as written, the template should not
be protected. If the template is protected, you receive the following
error message:
The context cannot be modified."

Follow the steps listed immediately after that statement, to unprotect
the template and save it.

The AutoNew macro in the article contains a statement that protects
the new document for forms, while the template remains unprotected.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top