Unable to change the Tab Sequence on a Microsoft Word 2007 Form

B

Brian Drab

I'm using Microsoft Word 2007 albeit designing a form in compatibility mode
so other users with older versions of Word can use. Instead of using Form
Fields we elected to use TextBoxes. After we designed the form we protected
it for form fields and began to use it. Everything works except for the tab
order. It doesn't tab in the order that we want it however we can't find a
way to change this behavior.

Any ideas? We have done everything we can think of. We even put code in on
the KeyUP event of every text box to try and go to the proper text box but
this doesn't work properly either.

I can send you the form if it will help as well. Thank you.
 
J

Jialiang Ge [MSFT]

Good morning Brian. Welcome to Microsoft Newsgroup Support Service! My name
is Jialiang Ge [MSFT]. It¡¯s my pleasure to work with you on this issue.

As you may have found, Word does not have built-in options to customize the
tab order of the textboxes. This limit is documented at a Word MVP site:
http://word.mvps.org/FAQs/TblsFldsFms/SetTabOrder.htm

However, we have workarounds. The above link demonstrates two possible
solutions. You may want to try them. Another working example on my side is
by using TextBox¡¯s KeyDown event + bookmark. Let me explain it in detail:

Suppose that we have three textboxes in a line: TextBox1, TextBox2,
TextBox3. The default tab order of Word is TextBox1->TextBox2->TextBox3. In
order to jump from TextBox1 to TextBox3, we first add KeyDown event handler
for TextBox1:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
End Sub

Second, I add a bookmark inside TextBox3 by
1. exit the ¡°Design Mode¡± of form
2. click (put the cursor) inside TextBox3
3. go to the Insert ribbon of Word 2007, click on ¡°Bookmarks¡± in the
¡°links¡± tab.
4. add a bookmark named ¡°Text3¡±

Third, we replace TextBox1_KeyDown event handler with this:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = 9 Then
ActiveDocument.Bookmarks("Text3").Select
End If
End Sub

Last, protect the document to allow ¡°filling in forms¡± and test our works.

Note, I choose to use a bookmark instead of
If KeyCode = 9 Then
TextBox3.Activate
End If
because TextBox3.Activate is not allowed after the document is protected
with ¡°filling in forms¡±.

Brian, I can send you my test document if it will help as well. Please let
me know whether the above solution is helpful or not, or please tell me
your email by sending one to my mailbox: (e-mail address removed) so that I can
send my test document to you.

Regards,
Jialiang Ge ([email protected], remove ¡®online.¡¯)
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Brian Drab

Unfortunately this didn't work. We get the same results. If I could send you
my document that would be best however if not, your sample document would be
great.

I'll try sending you our document at your email address. Thank you.
 
J

Jialiang Ge [MSFT]

Hello Brian,

I see the differences between your document and mine. Let's first look at
the resolution of your attachment, then look into the detailed causes.

*RESOLUTION*

Step1. Replace all the KeyUp events with KeyDown.
Step2. Add this line after bookmark.select:
KeyCode = 0

Thus, an example of the resulting KeyDown event handler is:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = 9 Then
ActiveDocument.Bookmarks("Text2").Select
KeyCode = 0
End If
End Sub

*CAUSE*

1. Why does the solution that I posted in the public newsgroup works on my
side, but not for your document?

It's because my solution steps were based on TextBox active controls in
Word. I misunderstood your meaning of "TextBox" in the beginning.

2. Why does the cursor jumps from TextBox1 to TextBox2, and to TextBox3
when we press Tab in TextBox1 inside your document?

TextBox shape behaves differently from the above-mentioned TextBox ActiveX
control. When we press Tab, it first jumps to TextBox2 due to our keydown
event handler (Bookmarks("Text2").Select), then it jumps to TextBox3
because of our press of Tab (the original Tab command is processed here).
Therefore, a quick resolution of the issue is to cancel the Tab command
after our KeyDown event handler: KeyCode = 0.

Please let me know if you have any other concerns or questions. Thanks

Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
B

Brian Drab

Fantastic!! Thank you. You not only answered my question but explained "WHY"
which I appreciate.
 

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