WD2000: How to Control the Tabbing Order in a Form

ID: Q212378


The information in this article applies to:
  • Microsoft Word 2000


SUMMARY

By default, when you fill in an online form, Word positions the insertion point in the first form field and moves from one field to the next in a left-to-right, top-to-bottom order when you press TAB. To change the default tabbing order, use the procedure described in the "More Information" section of this article.


MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft Support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp

Use one of the following methods as a workaround.

Method 1: Create a Single Exit Macro for All Form Fields

Create a macro similar to the following example. For each form field in your form, specify this macro as the exit macro.

In the Select Case statement, list each form field for which you want to change the tabbing order.

NOTE: The bookmark name in each Case statement below should be in all lower case characters.

    Sub TabOrder()
      Dim sTabTo As String
      Dim dlgForm As Dialog
      ' Unprotect the document.
      If ActiveDocument.ProtectionType <> wdNoProtection Then
         ActiveDocument.Unprotect
      End If
      Set dlgForm = Dialogs(wdDialogFormFieldOptions)
      ' Reprotect the document preserving form field contents.
      If ActiveDocument.ProtectionType = wdNoProtection Then
         ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
      End If
      Select Case LCase(dlgForm.Name)
         Case "cc"
            sTabTo = "header"
         Case "header"
            sTabTo = "to"
         Case "to"
            sTabTo = "from"
         Case "from"
            sTabTo = "memo"
         Case "memo"
            sTabTo = "subject"
         Case "subject"
            sTabTo = "cc"
         Case Else
      End Select
      Selection.GoTo What:=wdGoToBookmark, Name:=sTabTo
   End Sub 

Method 2: Create a Separate Macro for Each Form Field

Create a new exit macro for each form field that contains a Selection.GoTo statement that moves the insertion point to the next form field you want when you press the TAB key.

TIP: To easily identify each macro, give the macro a name that describes its functionality. For example, use the name GoToSubject for the exit macro that moves the insertion point to the Subject form field.

The following sample exit macro, named GoToSubject, moves from the current form field to the Subject form field:

   Sub GoToSubject()
      Selection.GoTo What:=wdGoToBookmark, Name:="Subject"
   End Sub 

For additional information about using the sample code in this article, please see the following article in the Microsoft Knowledge Base:
Q212536 WD2000: How to Run Sample Code from Knowledge Base Articles

Additional query words: vb vba vbe tabs tabbed

Keywords : kbmacro kbusage kbdta kbwordvba wd2000
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: November 13, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.