View Single Post
  #4   Report Post  
Jay Freedman
 
Posts: n/a
Default

On Wed, 27 Jul 2005 15:16:06 -0700, "granifty"
wrote:

I have a form that is locked, except for one line. I need to be able to tab
from that one line (in a table) to the first form field (in the following
table). Onscreen, it appears to be one table, but there is a continuous page
break separating the rows. Is there a way to get the tab to NOT enter a new
row, but to go to the form field in the protected portion of the document?


It should be possible to write a macro to do that. The idea is to
place a macro in the template for the form, and name the macro
NextCell so it runs when the Tab key is pressed in any table cell. The
macro checks which cell you're leaving. If it's the one where you
want to jump to a form field instead, it does that; otherwise it just
moves to the next cell.

This particular version of the macro assumes that the table you're
leaving is the first table in the document, indicated by .Tables(1).
It also assumes that the form field you want to go to is the first
form field in the document, indicated by .FormFields(1). It could be
simplified a bit if you want to hard-code the row and column numbers.

Public Sub NextCell()
Dim oRg As Range
Dim nRow As Long, nCol As Long

With ActiveDocument.Tables(1)
nRow = .Rows.Count
nCol = .Columns.Count
Set oRg = .Cell(nRow, nCol).Range
If Selection.Range.InRange(oRg) Then
ActiveDocument.FormFields(1).Select
Else
Selection.Cells(1).Next.Select
Selection.Collapse wdCollapseStart
End If
End With
End Sub

See http://www.gmayor.com/installing_macro.htm if necessary.

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