Word forms

Posted on 2011-10-19
Last Modified: 2012-05-12
I really need some help here.

I need to create a form as per attachment and I'm having the following problems

1. Each time I enter data in a first field, it moves the adjacent field
2. I need the Enter key to behave like a Tab
3. I need a button that will email this form on completion.


Question by:Bianchi928
    LVL 4

    Expert Comment

    Is this what you want?

    Made it into a template so you can use it as a real form. To edit, right click and say open.

    To go to next field, Enter
    To make a new line in a field, Shift+Enter

    LVL 4

    Expert Comment

    *please note macros will need to be enabled for this to work as requested.

    Word has an inbuilt Send To mail function (eg located in file menu in word 2003). If you really want a button, need to know what version of Word your using as the methods can be slightly different.
    LVL 76

    Expert Comment

    Question 1
    The document that you have posted looks like one to be printed as a blank for filling in by hand.

    To create a Word document form, you need to use Form Fields. When designing a Word document form, show the Forms toolbar. It would also help to show formatting characters - the Show/Hide button (¶) button  will toggle their display.

    I have copied the first few lines of the document and shown how to use form fields, tab stops and tab leaders as an attempt to recreate the original. The document is forms-protected, but without a password.

    Question 2
    This is not possible with Word document. The enter key is used to create a new paragraph.  If you need fuller windows form  interactivity, you could consider capturing the data on a VBA userform, and copying the data on to the document.
    LVL 76

    Expert Comment

    Question 3
    This is another subject. There is a mail item in the File menu. If this is not sufficient I suggest that you raise a separate question. It will require a non-trivial amount of VBA.
    LVL 76

    Expert Comment

    To question 2, I should have said that it isn't possible without VBA.

    In the interest of this site's philosophy as a how-to site as opposed to a do-it-for-you site, SPC_75's document shows how by using some VBA code. I will leave it  to the SPC_75 to post the code in a snippet.
    LVL 4

    Accepted Solution

    Thanks Graham.

    1. The moving fields can be solved by proper formatting, in this case I used columns (see example document) though tab stops work just as well (many ways to skin a cat).

    2.The code for VBA to change enter key functionality can be found here:;en-us;211219
    (or by pressing Alt+F11 in the example document I posted.)

    Sub EnterKeyMacro()
    ' Check whether the document is protected for forms
    ' and whether the protection is active.
       If ActiveDocument.ProtectionType = wdAllowOnlyFormFields And _
       Selection.Sections(1).ProtectedForForms = True Then
          ' Retrieve the bookmark of the current selection.
          ' This is equivalent to the name of the form field.
          myformfield = Selection.Bookmarks(1).Name
          ' Go to the next form field if the current form field
          ' is not the last one in the document.
          If ActiveDocument.FormFields(myformfield).Name <> _
          ActiveDocument.FormFields(ActiveDocument.FormFields.Count) _
          .Name Then
             ' If the current form field is the last one,
             ' go to the first form field in the document.
          End If
       ' If the document is not protected for forms,
       ' insert a tab stop character.
          Selection.TypeText Chr(13)
       End If
    End Sub
    Sub AutoNew()
     ' Do Not protect the template containing these macros.
       CustomizationContext = ActiveDocument.AttachedTemplate
       ' Bind the ENTER key to the EnterKeyMacro.
       KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), _
       KeyCategory:=wdKeyCategoryMacro, Command:="EnterKeyMacro"
       ' Reprotect the document with Forms protection.
       ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
    End Sub
    Sub AutoOpen()
    ' This macro will reassign the ENTER key when you open an existing
    ' Word form fields document.
       CustomizationContext = ActiveDocument.AttachedTemplate
       ' Bind the Enter key to the EnterKeyMacro.
       KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), _
       KeyCategory:=wdKeyCategoryMacro, Command:="EnterKeyMacro"
    End Sub
    Sub AutoClose()
       CustomizationContext = ActiveDocument.AttachedTemplate
       ' Disables prompt to save template changes.
    End Sub

    Open in new window


    Author Closing Comment

    Wasn't a complete solution to my request.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
    Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
    This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
    Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now