Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Dec 2001
    Location
    Forres, Moray, Scotland
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form Fields (2000 SR1)

    Help! Is there an easy way to enter text into a protected form field and to have the same text appear in other form fields in the same document? I am not a VBA expert!!

    Help appreciated,

    John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Form Fields (2000 SR1)

    You can write a macro to do this in the following way. It assumes that you want to copy the text entered in the first form field in the document to the second form field. You can adapt the numbers in the macro line below to your own needs.

    Select Tools/Macro/Macros...
    Type a name in the Macro name box, for instance CopyValue
    You probably want this macro to be available in the current document only, so select the name of the document in the combo box below.
    Click Make (or Create - I am using the Dutch version of Word, so I do not know the exact caption in English)
    You are taken to the Visual Basic editor. Type
    ActiveDocument.Fields(2).Result = ActiveDocument.Fields(1).Result

    That is all there is to creating a macro! Now we need to do something with it.

    Switch back to Word (using the Windows Task Bar or Alt+Tab)
    Double click the first form field.
    Select the name of the macro you just created (CopyValue) in the Exit field combo box.
    Now protect your document for forms (Tools/Protect document...)
    Enter some text in the first form field and tab away from it. The text should be copied to the second form field.

  3. #3
    New Lounger
    Join Date
    Dec 2001
    Location
    Forres, Moray, Scotland
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Fields (2000 SR1)

    Hi Hans, thanks for taking the time to reply. I did exactly as you said and created a macro called CopyText but when I entered text into the first field and 'tabbed' out I received the following:

    Runtime Error '509'

    The CopyText command is not available because the document is a protected document.

    Perhaps I did not explain my question enough? I would like to be able to be able to enter text in a text box and to have the text appear in one (or more) text fields in the same protected document. Could it be I did something wrong in the second text field box? Do I need to add the macro again? If so is it in the entry or exit box. Do I follow the same procedure with a third box?

    Regards,

    John

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Form Fields (2000 SR1)

    Hello John,

    I have attached a sample document made in Word 97. It contains four form fields. When I protect it for forms and update the first one, the second and fourth are updated too, while the third one stays unchanged.

    If it doesn't work for you, it may be due to a difference between Word 97 and Word 2000. In that case, I can't help you, but I'm sure someone else on the lounge will assist.

    Regards,
    Hans
    Attached Files Attached Files

  5. #5
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Fields (2000 SR1)

    There's a non-VBA variation which does not use form fields to copy to. It uses fields which are not modifiable, which may not suit.

    Steps.
    1. Insert a form field. Double click on it, give it a name (eg myText). Ensure "Calculate on exit" is checked.

    2. Go to where you want it copied. Insert, Field, select "Links and references". Select "Ref", and click on the "Options" button. Click on the Bookmarks" tab, select "myText" from the list, and click "Add to field". Click OK twice.

    3. Protect the document and try it out.

    To view where you've got fields, click Alt + F9 to toggle the way codes are viewed.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  6. #6
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Form Fields (2000 SR1)

    Hi John,

    Do you really need it to appear in other form fields? Would it be OK if it just appeared in the document where you want? If so, your initial form field has a bookmark assigned to it (and you can change this). Assume the bookmark is Text1. Wherever you want the contents of that field to appear in your document, insert a cross reference field using Insert=>Field. The field should look like { REF "Text1" } if you have field codes displayed.

    In your source form field, be sure to check the box for "calculate on exit" in the field properties.

    Hope this helps. For more on protected forms, follow the links at Word Web Resources - Forms (addbalance.com/word/wordwebresources.htm) especially Dian Chapman's series of articles. For more on other fields, follow the links at Word Web Resources - Fields (addbalance.com/word/wordwebresources.htm).
    Charles Kyle Kenyon
    Madison, Wisconsin

Posting Permissions

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