Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Tabs in a Word form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
An American Roundeye - 25 Sep 2007 14:24 GMT
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.

Signature

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.

Jean-Guy Marcil - 26 Sep 2007 23:47 GMT
An American Roundeye was telling us:
An American Roundeye nous racontait que :

> At Stefan's suggestion, I am posting this here.
>
[quoted text clipped - 4 lines]
> 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?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

An American Roundeye - 27 Sep 2007 14:21 GMT
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.

> An American Roundeye was telling us:
> An American Roundeye nous racontait que :
[quoted text clipped - 10 lines]
> 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?
Jean-Guy Marcil - 28 Sep 2007 00:55 GMT
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
[quoted text clipped - 7 lines]
>
> 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.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.