• Help with Word Forms

    Author
    Topic
    #353130

    Does anyone know of a way to control the direction or order of the tab key when using a Word form. The form has been established in a table and is protected. As you know, the default direction of the tab key in a table is left to right then down. We need to define the direction and VBA is not an option.

    Chance

    Viewing 1 reply thread
    Author
    Replies
    • #515656

      I grabbed this from the Help File – perhaps it gives you some ideas. This method does include macros though so perhaps is excluded by your phrase “VB is not an option”, but it’s all I’ve got to offer.

      [indent]


      The TAB key doesn’t move the insertion point to the correct form field.
      Depending on how your form is designed, the TAB key may not move the insertion point to the correct form field. You can specify that the insertion point automatically moves from one form field to another by using an on-exit macro.
      How?

      Automate your form
      Any macro saved in the form template can run automatically when the insertion point enters or exits a form field. For example, if a user selects a Married check box, an exit macro could activate other related fields, such as Name of Spouse.

      For information about writing macros in Visual Basic that customize the behavior of ActiveX controls, click .

      Open the template that contains the form you want to change.

      Remove protection from the form template by clicking Protect Form on the Forms toolbar.

      Create the macros you want to use, and store them in the form template.
      If another template contains macros you want to use, copy them into the form template.

      How?

      Double-click the form field you want to assign a macro to.

      To run a macro when the insertion point enters the form field, click the macro in the Entry box.
      To run a macro when the insertion point exits the form field, click the macro in the Exit box.

      Note If you store the entry and exit macros in your Normal template and then distribute a form to others, the entry and exit macros may not run because the macros won’t be available to the users. You must store macros you use in the form in the form template.


      [/indent]

      • #515746

        Thanks phanks …. I think I can use this since it should be transparent to the users who are barely computer literate. BobD’s suggestion is essentially the same. I’ve tried it but am running into a error in code that I can’t seem to figure out what causing it. See my post below please.

    • #515711

      *** Geoff W. URL markup added ***

      Look at Q159898

      http://support.microsoft.com/support/kb/ar…s/Q159/8/96.ASP

      Works with 97 & 2000.

      • #515747

        Bob Thanks for your response …. I’ve tried this but am running into a code error that I can’t seem to troubleshoot. See my post below please for details.

        Chance

        • #515748

          Here’s the test code ….
          Sub TabOrder()
          Dim sTabTo As String
          Dim dlgForm As Dialog
          Set dlgForm = Dialogs(wdDialogFormFieldOptions)
          Select Case LCase(dlgForm.Name)
          Case “Text1”
          sTabTo = “Text2”
          Case “Text2”
          sTabTo = “Text3”
          Case “Text3”
          sTabTo = “Text4”
          Case “Text4”
          sTabTo = “Text5”
          Case “Text5”
          sTabTo = “Text6”
          Case “Text6”
          sTabTo = “Text7”
          Case “Text7”
          sTabTo = “Text8”
          Case “Text8”
          sTabTo = “Text9”
          Case “Text9”
          sTabTo = “Text10”
          Case “Text10”
          sTabTo = “Text11”
          Case “Text11”
          sTabTo = “Text12”
          Case “Text12”
          sTabTo = “Text13”
          Case “Text13”
          sTabTo = “Text14”
          Case “Text14”
          sTabTo = “Text15”
          Case “Text15”
          sTabTo = “Text16”
          Case “Text16”
          sTabTo = “Text17”
          Case “Text17”
          sTabTo = “Text18”
          Case “Text18”
          sTabTo = “Text1”
          Case Else
          End Select
          ActiveDocument.Bookmarks(sTabTo).Select
          End Sub

          It hangs up on ActiveDocument.Bookmarks(sTabTo).select. The error is “Requested member of the collection does not exist.” as soon as I tab from Text1 form field. I’ve double checked each of the bookmarks in each of the form fields and all seem to be spelled correctly and match code references. There is also a bookmark set in each form field. Any ideas????

          I appreciate your help ….

          • #515835

            Please reread Q159896 and you will see:

            Note: Each Case statement below should be in all lower case.

            Replace yours with something like the below:

            Sub TabOrder()

            ‘ TabOrder Macro
            ‘ Macro created 02/22/01

            Dim sTabTo As String
            Dim dlgForm As Dialog
            Set dlgForm = Dialogs(wdDialogFormFieldOptions)
            Select Case LCase(dlgForm.Name)
            Case “text1”
            sTabTo = “text2”
            Case “text2”
            sTabTo = “text3”
            Case “text3”
            sTabTo = “text4”
            Case “text4”
            sTabTo = “text1”
            Case Else
            End Select
            ActiveDocument.Bookmarks(sTabTo).Select
            End Sub

            This works for me w/Word97.

            • #515917

              Thanks Bob …. got it working just fine now … I had thought it might have something to do with the case and had tried to make that change … but what I also need to do is to have lower case for the bookmark field name in the field properties. When I made both lower case it worked.

              Thanks again ……Chance

            • #515945

              Hi Bob:

              I have a question. Why do you have to use lowercase for “text1”, etc. since the bookmark obstensibly uses “Text1”.

              Thanks.

            • #515977

              Phil,

              Only the Case statement needs lower case as shown by the note in Q159896.
              “Note: Each Case statement below should be in all lower case. ”
              Case “text1”
              As I dislike typing I use copy/paste extensively.
              The lines below produce the same results in the macro I posted above.
              sTabTo = “text2”
              sTabTo = “Text2”

              No changes to default bookmark names were done. They are still Text1, . . .

              Case “Text1” – give the error while
              Case “text1” – executes properly. That’s all I know.

              Bob_D

            • #515979

              It needs to be lower case because of the way MS designed it:


              Select Case LCase(dlgForm.Name)

              I guess this was to avoid case mismatches, but…

            • #515980

              Thanks, Bob. Maybe some day I’ll get around to learning VBA. Something to do in my spare time.

            • #515992

              Phil,

              It seems like heavy stuff, but, to my mind, it’s WELL worth it.

              You can do so much with Word with the extra help from VBA.

              I first got switched on to VBA for Word when my wife came home from her travel agency, and told me how they generated standard letters for her travel agency just by entering a few fields. I had never realised (5 years ago) that something like that was possible from Word.

              Since then, I’ve produced a standard set of forms for our users, where common details (name, phone, address, etc) are filled in automatically. If they change any fields, those changes are reflected in the next form they fill in.

              It wan’t that hard to achieve. The quantum leap was to get the idea that it could be done.

              With some knowledge, and lots of ideas, you can achieve heaps.

              Just some thoughts

            • #516020

              Hi Geoff:

              Thanks for the encouragement. I know you’re right. I’ll probably take the plunge this summer.

            • #516204

              I HOPE you’re talking about this summer Australian time, not summer in the North!

              To start is not a big plunge. Just record a macro and see what it does. Or copy some of the simple macros posted here and run them.

              To learn it all properly- that’s another story. I think we’re all learning.

            • #516228

              Geoff, thanks for the heads up on your forms technique and furnishing the code. Gives me something to while away the time in the sleepless wee hours.

              BTW, what is the references to the Australian summer? I searched the thread on this and wondered what I missed.

            • #516229

              he he he – I see Phil’s one liner now about tackling his form building job in the summer. I missed that – but then it’s 4am here and I’m working lights out so as not to disturb my daughter so I guess I’m missing things. Sorry.

            • #516103

              k Geoff – you’ve got my attention with this statement [indent]


              Since then, I’ve produced a standard set of forms for our users, where common details (name, phone, address, etc) are filled in automatically. If they change any fields, those changes are reflected in the next form they fill in.


              [/indent] What exactly do you mean? How did you do it so that multiple forms recognized it? I have a bizillion forms to automate where fields have the same info over and over again in the same form as well as in companion forms. Can you enlighten me with your magic ways?

            • #516202

              OK, thanks for the encouragement to expand!

              I have a standard naming for my form fields. “Name” is always the user’s name; “FullName” is always full name, etc- so that a field will always be filled in consistently.

              There is an “AutoNew” in an add-in (it could be in Normal.dot if you wnated it to) which goes through every form field on the document. It ignores any fields with no names, or any field which starts with “text”, “chec”, or “drop” (default names).

              If it is, for instance, “Name”, I have a look at the field “Name” in my settings name. If it exists, I insert that value of the field into that form field.

              I also have another standard name- if the name starts with “texttoday” it inserts todays date- it is still modifiable if I choose to allow a form field to be filled in.

              If I need form fields to be named for other reasons, I prefix the names with “text”.

              Here’s the code (sorry, naming convention is not consistent):

              Dim i As Integer
              Dim sType As String
              Dim sName As String
              Dim sResult As String
              Dim sStartupPath as String
              Dim blnProtected As Boolean
              
              On Error GoTo HandleErr
              sStartupPath = Options.DefaultFilePath(wdStartupPath) & "settings.ini"
              Application.ScreenUpdating = False
              blnProtected = False
              If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
                  ActiveDocument.Unprotect
                  blnProtected = True
              End If
              
              For i = 1 To ActiveDocument.FormFields.Count
                sName = ActiveDocument.FormFields(i).Name
                sType = UCase(Mid(sName, 1, 4))
                If sType  "TEXT" And sType  "" And sType  "DROP" And sType  "CHEC" Then
                  Selection.GoTo What:=wdGoToBookmark, Name:=sName
                  sResult = Trim(System.PrivateProfileString(sStartupPath, "MS Word User", sName))
                  ActiveDocument.FormFields(i).Result = sResult
                End If
                If Mid$(UCase$(sName), 1, 9) = "TEXTTODAY" Then
                  ActiveDocument.FormFields(i).Result = Now
                End If
              Next i
              
              If blnProtected Then
                ActiveDocument.Protect Type:=wdAllowOnlyFormFields, noreset:=True
              End If
              
              
              

              If there’s a group of fields together, as there typically
              are, I have a “macro on exit” attached to the last field
              which does the revers, and stores the values back on the
              ini file.

            • #516027

              It’ll probably because a part of the VBE engine is using the string literally, in which case (ugh!) “Text” is quite different from “text”.

              I hate it when an application forces case-sensitive in one part and is insensitive in another. That may be what you’ve discovered.

    Viewing 1 reply thread
    Reply To: Help with Word Forms

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: