PDA

View Full Version : How to set tab order by a macro in ms word



infomamun
06-19-2018, 09:25 PM
I have a ms word form with activeX control (not the form control). Suppose I have two textboxes and two option button as follows:


Name: [textBox1]
Address: [textBox2]
Gender: [opt1] Male [opt2] Female




Now if I want a tab order, I have to add following macro:


PrivateSub textBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,ByVal Shift AsInteger)
If KeyCode =9Then
textBox2.Activate
EndIf
EndSub

PrivateSub textBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,ByVal Shift AsInteger)
If KeyCode =9Then
opt1.Activate
EndIf
EndSub

PrivateSub opt1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,ByVal Shift AsInteger)
If KeyCode =9Then
opt2.Activate
EndIf
EndSub


Now in my real form there are 20 text boxes and 12 option buttons, so it is quite boring to write down keydown event for each form field. How can I write a macro so that it will first get the name of current form field on keydown (and validating it as tab keydown) and then go to next form field. For the sake of tab order, I will then rename all form field chronologically such as field1, field2, field3......... etc, so that with an increment the code can move the tab to next form field.
Any help will be appreciated.

As I need urgent help, I have posted this in stackoverflow forum also. Who will answer acceptable help, will get credit. Link is:
https://stackoverflow.com/questions/50939997/how-to-set-tab-order-by-a-macro-in-ms-word

gmayor
06-20-2018, 12:07 AM
As you appear to be at the stage of creating the form, do yourself a favour and save a lot of grief later by using content controls for the from fields in this document.
You might even find http://www.gmayor.com/insert_content_control_addin.htm useful.

infomamun
06-20-2018, 04:54 AM
There is a Donate button in your screen shot of "content controls" UI. Is it a part of the add-in and can't be omitted?

gmayor
06-20-2018, 05:29 AM
All the add-ins on my web site are donationware. If you find it useful, send a donation. The format is what you see is what you get.

Paul_Hossler
06-20-2018, 07:18 AM
GM -- thought I'd take a look at the CC addin


Norton AV didn't like the EXE in the ZIP file

Thought I'd check before I overruled the AV to make sure that there's no issues

I just thought that it's a little unusual to have a EXE with a DOCM file

22457
22458