How to trap ENTER key in WORD table

P

pwrichcreek

I have a protected document with form fields and tables in WORD 2002. When a
users hits the ENTER key inside a table, WORD simply adds a row's worth of
space to the cell. (Not sure why this happens when the table is protected.)
I'd like to change this behavior so that the ENTER key simply moves the
cursor to the next cell. I've seen examples of trapping the TAB key and
substituting the NextCell command for that. I suppose I can do that with the
ENTER key; but the main problem may be that I only want to alter this
behavior while inside the table, not within other sections of the form.

So, my questions are:

a. Can I substitute NextCell for the ENTER key?
b. Can I limit that behavior to the table, and let the ENTER key do its own
thing when outside the table?
c. Is there a way to tell inside my code whether the cursor is current
inside the table, if the table is in its own section? Can I utilize bookmarks
to identify the start and end of the table and somehow make use of this?

TIA,

Phil
 
J

Jean-Guy Marcil

pwrichcreek was telling us:
pwrichcreek nous racontait que :
I have a protected document with form fields and tables in WORD 2002.
When a users hits the ENTER key inside a table, WORD simply adds a
row's worth of space to the cell. (Not sure why this happens when the
table is protected.) I'd like to change this behavior so that the

This is to be expected if you row height is not set to an exact height
(Table Properties dialog > Row tab)
ENTER key simply moves the cursor to the next cell. I've seen
examples of trapping the TAB key and substituting the NextCell

The NextCell routine will not work with a protected document.
command for that. I suppose I can do that with the ENTER key; but the
main problem may be that I only want to alter this behavior while
inside the table, not within other sections of the form.

So, my questions are:

a. Can I substitute NextCell for the ENTER key?

Not in a protected document
b. Can I limit that behavior to the table, and let the ENTER key do
its own thing when outside the table?
Yes

c. Is there a way to tell inside my code whether the cursor is current
inside the table, if the table is in its own section? Can I utilize
bookmarks to identify the start and end of the table and somehow make
use of this?

Selection.Information(wdWithinTable)
returns True if the current selection starts in a table.

See
http://support.microsoft.com/?kbid=211219
for a set of macros to make the Enter key act like the Tab key in a
protected form.

Just add something regarding trhe current selection.Information:

If Selection.Information(wdWithinTable) Then
'Do something to alter Enter key behaviour
'Else do nothing, i.e do regular Enter key behaviour
End If

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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