Tabs in a Word form

  • Thread starter An American Roundeye
  • Start date
A

An American Roundeye

At Stefan's suggestion, I am posting this here.

Answer
By: Stefan Blom In: microsoft.public.word.docmanagement

I believe you can do this by overriding the NextCell command. For
assistance, ask in a programming newsgroup such as
microsoft.public.word.vba.general.

--
Stefan Blom
Microsoft Word MVP



I have a problem I can't figure out. I have built a form that will be used
as a template for project managers. I have sections in the form that are
locked, through which the user tabs and enters information into the form.
Other sections are unlocked so the user can enter free form comments and
text. Since this is built in a table, when you hit the tab key in these
unlocked sections, it immediately inserts a new line in the table/form and
moves the focus to that new cell.

I want the tab function to work so it will move from one cell to the next
existing cell in the sections of the form that are not locked, allowing the
user to tab to the next cell that requires free form text entry. As it is,
the form just throw a new row in the table, and continues to do so as long at
the user hits the tab key. The only way to get out of it is to move the
cursor to the cell you want to enter text into and click inside the cell.
Very frustrating to PMs who are trying to get these admin things done as
expeditiously as possible.

Is there a simple way to do this? Or even a hard way that will be
transparent to the user?

Thanks in advance for any assistance you can provide.
 
J

Jean-Guy Marcil

An American Roundeye was telling us:
An American Roundeye nous racontait que :
At Stefan's suggestion, I am posting this here.

Answer
By: Stefan Blom In: microsoft.public.word.docmanagement

I believe you can do this by overriding the NextCell command. For
assistance, ask in a programming newsgroup such as
microsoft.public.word.vba.general.

Just to be clear, what do you want the TAB key to do once it reaches the
last cell in a table located in an unprotected section of the document?

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

An American Roundeye

I would like to be able to tab through the first section, which is a locked
form, at the end of it move into and unprotected section (which is actually
made up of several small tables of two rows, each containing one row for the
header and a second for text entry) and tab from cell to cell and section to
section - allowing PMs to make any free text entries necessary in each
section, and continue the ability to tab from cell to cell (moving through
multiple, 2 row separated tables) and then enter a protected section at the
end of the form to complete it.

If this explanation remains unclear, please let me know.
 
J

Jean-Guy Marcil

An American Roundeye was telling us:
An American Roundeye nous racontait que :
I would like to be able to tab through the first section, which is a
locked form, at the end of it move into and unprotected section
(which is actually made up of several small tables of two rows, each
containing one row for the header and a second for text entry) and
tab from cell to cell and section to section - allowing PMs to make
any free text entries necessary in each section, and continue the
ability to tab from cell to cell (moving through multiple, 2 row
separated tables) and then enter a protected section at the end of
the form to complete it.

If this explanation remains unclear, please let me know.

Here a little something to get you going:

'_______________________________________
Sub NextCell()

Dim lngCol As Long
Dim lngRow As Long
Dim lngColTotal As Long
Dim lngRowTotal As Long
Dim lngSecTable As Long
Dim lngSecTableTotal As Long
Dim rgeTemp As Range
Dim lngSec As Long

With Selection
'Get ndex of current section
lngSec = .Sections(1).Index
'Make sure cursor in table
Set rgeTemp = ActiveDocument _
.Range(.Sections(1).Range.Start, .Cells(1).Range.End)
'Get Index of current table
lngSecTable = rgeTemp.Tables.Count
'Get total of table in current section
lngSecTableTotal = .Sections(1).Range.Tables.Count
'Get index of current column
lngCol = .Information(wdEndOfRangeColumnNumber)
'Get index of current row
lngRow = .Information(wdEndOfRangeRowNumber)
'Get total column in table
lngColTotal = .Tables(1).Columns.Count
'Get total row in table
lngRowTotal = .Tables(1).Rows.Count
'Check if in last cell
If lngCol = lngColTotal And lngRow = lngRowTotal Then
'If so, go to next table
'Check if in last table
If lngSecTable = lngSecTableTotal Then
'if so, go to next formfield
ActiveDocument.Range.Sections(lngSec +
1).Range.FormFields(1).Range.Select
Else
.Sections(1).Range.Tables(lngSecTable + 1).Cell(1,
1).Range.Select
End If
Else
'If not, go to next cell
If lngCol < lngColTotal Then
.Tables(1).Cell(lngRow, lngCol + 1).Range.Select
Else
.Tables(1).Cell(lngRow + 1, 1).Range.Select
End If
End If
End With

End Sub
'_______________________________________


You would probably need to add code to check for last section in document
and other things like that.

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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