Written by Allen Wyatt (last updated October 11, 2021)
This tip applies to Word 2007, 2010, and 2013
Dori Lynn's customers use Word to create simple forms. One of the things they do quite often is use tables for ease in moving through the form. Dori Lynn wonders if there is a way to tab from the last cell (field) of one table to the first cell in the next. Right now if she tabs at the end of the table, it creates a new row.
Pressing the Tab key when the insertion point is in a table cell normally moves the selection to the next cell in the table. At the last cell in the table, the Tab key adds a new row of cells to the bottom of the table and moves the insertion point to the first cell of the new row. That is obviously not the behavior that Dori Lynn is looking for.
There are a couple of approaches you can use for this problem. One is to remember that you can use the Object Browser to move from one table to the next. That, of course, means that you can't use the Tab key to move from table to table, but you can click the Object Browser button (bottom-right corner of the screen, click the small "ball" between the double up- and down-arrows, then choose Browse by Table from the options) to find those tables.
If you actually want to use the Tab key, then you are going to need to create a macro. Pressing the Tab key when the insertion point is within a table causes Word to execute a command called nextcell, which in turn executes the MoveRight command. It is possible to write a custom nextcell command that forces Word to do what Dori Lynn wants.
How you modify existing Word commands is covered in other WordTips. The custom nextcell routine, below, traps the Tab key and moves the selection to the next cell unless the current cell is the last cell of the table. If it is, then it moves to the next table in the document. If there are no further tables in the document, then the insertion point remains in the last cell of that last table.
Sub nextcell() Dim oCell As Cell With Selection Set oCell = .Cells(1).Next If oCell Is Nothing Then .Move unit:=wdTable, Count:=1 Else .MoveRight Unit:=wdCell End If End With End Sub
The subroutine will work correctly with tables that have vertically and horizontally merged cells. It will process tables within tables, but will stop at the last cell of the inner table.
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (5673) applies to Microsoft Word 2007, 2010, and 2013.
The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!
When you print, do you get an extra blank page printed at the end of the document? It could be because of the final ...
Discover MoreWhen working with tables, a common editing task is to combine two tables into one. Sometimes, though, you may run into ...
Discover MoreWhat do you do if you add numbered captions to an element of your document (such as tables) and Word skips a number? ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2022-04-19 22:52:58
Aaron
Where do I put this Macro? I have looked at the section you referenced and I don't see where there is a section in word commands called Tab that I can place the Macro in.
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2023 Sharon Parq Associates, Inc.
Comments