Here's a topic from my web site, http://www.wordmacros.com, adapted to your
needs:
TOPIC: Change the behavior of the TAB key inside a table cell.
Note:
When the cursor is inside an unprotected table and you press the Tab key,
Word runs a built-in routine called NextCell. If you create a custom version
of this routine, Word will run your version instead of the built-in version.
If the table is in a section of a document protected for forms, Word runs a
built-in routine that lies beyond the reach of Visual Basic for
Applications.
Solution:
Use a macro to test the cursor position and move to the next cell only if
there's another cell to move to.
Steps to follow:
1. Click Macro on the Tools menu, then click Macros... on the submenu.
2. Under Macro Name, enter NextCell, then click Create.
Word will show the following code, which represents the built-in NextCell
routine:
Sub NextCell()
'
' NextCell Macro
' Moves to the next table cell
'
Selection.MoveRight Unit:=wdCell
End Sub
3. Replace the built-in code with the following Code:
This code is provided for illustrative purposes only and is not warranted to
be suitable for any particular business purpose. The code may be freely
copied for any lawful business purpose.
Sub NextCell()
If Selection.Information(wdEndOfRangeColumnNumber) _
< Selection.Information(wdMaximumNumberOfColumns) Or _
Selection.Information(wdEndOfRangeRowNumber) _
< Selection.Information(wdMaximumNumberOfRows) Then
Selection.MoveRight wdCell, 1
End If
End Sub
4. Select Save Normal on the File menu.
5. Select Close and Return to MS Word on the File menu.
6. Position the cursor in a table and press the TAB key.
7. If not satisfied with the results, modify the code in the NextCell macro.
8. To return the TAB key to its normal functionality, delete or rename the
NextCell macro.
HTH
--
Bill Coan
Microsoft Word MVP
Neenah WI 54956 USA
http://www.wordsite.com
Gail Edmonds <gedm...@mediaone.net> wrote in message
news:37DBD885...@mediaone.net...
> Is there ANY way (possibly a roundabout way with VBA) to prevent the TAB
key from adding a new row at the end of a table? I tried disabling Tab
using FINDKEY on wdKeyTab, but it only disables Tab outside of a table. Is
there a different keycode for Tab within a table? I know that it's drastic
to disable a key, but we can't come up with a better way to prevent the
table from growing.
> This is for a critical template that contains a table that spans the
second half of page 1 and all of page 2, in a 6-page document. The
company's requirements are that the user must not be able to make the table
grow past page 2 (it causes the document to exceed it's 6 page limit). We
can't use form fields instead of a table at this point in the document,
because they need to be able to format this area of text.
>
> Gail Edmonds
> gedm...@mediaone.net
>
>
gail
You're quite welcome, Gail. It's always nice to hear back. You'd be
surprised at how many threads trail off without any sense of resolution. I'm
glad you solved your problem and I'm glad I was able to help.
--
Bill Coan
Microsoft Word MVP
Neenah WI 54956 USA
http://www.wordsite.com
. . .
Gail Edmonds <gedm...@mediaone.net> wrote in message
news:37DDA70A...@mediaone.net...