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



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.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

On Wed, 08 Jun 2005 11:01:43 -0500, "Steven Marzuola (remove wax and
invalid for reply)" <marzgroups@xxxxxxxxxxxxxxxxxxxxx> wrote:

>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.)

.



Relevant Pages

  • RE: Word Templates
    ... that you have set forms protection on your template. ... you press the Tab key in the last cell of a table in one of these unprotected ... pressing the Tab key moves to the next ...
    (microsoft.public.word.docmanagement)
  • tab key jumps to next page
    ... I somehow have accidentally set it that when I push ... the tab key, it jumps to the next page to the right instead of the next ... I have even tried to overwrite it with a macro, ... will take the cursor to the cell below or the cell to the right, ...
    (microsoft.public.excel)
  • Re: How do I get a 2nd & 3rd page of the same label? Say an Avery
    ... MVP Microsoft [Publisher] ... cell, hit the tab key. ... (Some labels aren't as easy as this.) ...
    (microsoft.public.word.docmanagement)
  • Re: entering data
    ... Insert the following macro into your normal.dot template and it will hijack the use of the tab key in a table ... ' NextCell Macro ... ' Modified by Doug Robbins to move to the next cell in the column before moving to ...
    (microsoft.public.word.tables)
  • Re: Tab key
    ... > press the tab key twice! ... move the active cell one to the right after activating a cell in ... the column to be skipped over, or to move the active cell two cells to ...
    (microsoft.public.excel)