Consulting

Results 1 to 5 of 5

Thread: How to set tab order by a macro in ms word

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    How to set tab order by a macro in ms word

    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/...cro-in-ms-word


    Last edited by infomamun; 06-19-2018 at 09:28 PM. Reason: formatting

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •