TAB key appends new row to table - can this be turned off

  • Thread starter Steven Marzuola (remove wax and invalid for reply)
  • Start date
S

Steven Marzuola (remove wax and invalid for reply)

1. When you're in the last cell of a table, the TAB key appends a new
row to the table. Sometimes I want to turn off this feature. Is there
a way to do this? I have Word 2000.

2. IIRC some other version of Word used to offer the option. Am I nuts?

3. One reason I wanted this is to help with some macros that processed
each cell in a table. I wanted them to stop on the last cell, but they
wouldn't. Is there a way to instruct Word, using a macro, to move to
the next cell but NOT to create a new row if it's already in the last
cell? (rightmost cell of bottom row).

I know that there are VBA functions that tell you what row and column
you are in, and the table dimensions. Unfortunately they don't always
work correctly, especially if any cells in the table have been merged or
split, or tables of different sizes have been joined.

4. There's probably another way to cycle through table cells using VBA.
Any pointers?

(I had another reason for this request, other than writing a macro, but
I'm having a premature senior moment and can't remember it.)
 
J

Jay Freedman

Hi Steven,

1. No, you can't turn it off, other than using a key binding to
disable the Tab key. Read on, though -- you don't need to turn it off.
2. My memory only goes back to Word for Windows 2.0 :) and I don't
recall such an option.
3 & 4. Yes, there's another way to access all the cells in a table
without triggering the new row. It depends on using the .Next property
of the Cell object. It copes perfectly well with merged/split cells.
Here's a sample macro:

Sub TableDemo()
Dim oRg As Range
Dim oCell As Cell

' make sure there is a table
' (prevent an error message)
If ActiveDocument.Tables.Count = 0 Then
MsgBox "No tables!"
Exit Sub
End If

' start at top left
Set oCell = ActiveDocument.Tables(1).Cell(1, 1)

' since we know there is a table, it must have
' at least a Cell(1,1), so this loop will
' execute at least once
Do While Not oCell Is Nothing
' get its range
Set oRg = oCell.Range

' exclude end-of-cell mark from oRg
oRg.MoveEnd unit:=wdCharacter, Count:=-1

' make it bold
oRg.Bold = True

' display it
MsgBox oRg.Text

' go to the next cell
Set oCell = oCell.Next

' if that was the last one and there is
' no next cell, then oCell is now Nothing
' so loop will terminate
Loop
End Sub

I've set the followup for this thread to the
microsoft.public.word.vba.beginners newsgroup.
 

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