Microsoft Office Tutorials and References
In Depth Information
Tables: Suppressing New Rows When Tabbing
Note: This macro MUST be named NextCell, which is the name of the Word internal
command that is fired when Tab is pressed while your cursor is inside of a
table. In Word, a macro named with the same name as an internal command
will run in place of that command.
Tables: Suppressing New Rows When Tabbing
Use this procedure to suppress Word's default behavior, which creates a new
row when Tab is pressed in the last cell of a table.
Example file:
Scenario: In the previous macro, unlike the default
behavior, no new row is created when Tab is pressed in the
last cell. To do the same for normal table cell navigation
behavior when pressing Tab, use this variation of the
NextCell procedure.
View the Appendix to learn how to store this procedure
in a Standard module.
Option explicit¶
' * * * * *¶
Sub NextCell()¶
If Selection.Information(wdWithInTable) Then¶
'Variable declaration¶
Dim tbl As Word.Table, cel As Word.Cell¶
Set tbl = Selection.Tables(1)¶
Set cel = Selection.Cells(1)¶
'If not in the last cell, move to the next¶
If cel.RowIndex <> tbl.Rows.Count _¶
Or cel.ColumnIndex <> tbl.Columns.Count Then¶
'Move out of the table¶
Dim rng As Word.Range¶
Set rng = tbl.Range¶
rng.Collapse wdCollapseEnd¶
End If¶
End If¶
End Sub¶
Search JabSto ::

Custom Search