Results 1 to 11 of 11
  1. #1
    Star Lounger
    Join Date
    Dec 2000
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    More form field headaches

    I can't get the ExitMacro in WD97's form fields to run. Is this another Word bug or am I doing something wrong?

    Actually, maybe someone can suggest a better way of doing what I trying to do here with form fields:

    I have 2 form fields in a template which enables the user to enter or change information, for example, an invoice number. Once that happens, the invoice number (or whatever) automatically updates throughout the document because that value gets re-assigned to a regular Word field (like the COMMENTS field) which acts as a placeholder for the invoice number throughout the document.

    So I attempted to do this through the form field's ExitMacro, except apparently, it never runs.

    Any suggestions. Thank you.

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: More form field headaches

    Hi Stephan,

    Sounds like two possibilities:
    1) The macro actually isn't running.
    2) The macro is running but isn't performing the expected task.

    Maybe try putting a MsgBox "This is the start of the Exit macro" at the start of the macro.
    Dumb as it sounds, one of the things I do to suss out a part of a macro that isn't working (assuming the macro is not convenient to step through, for example part of a Document_New procedure) is to put MsgBox statements ("The value of myVariable is now " & myVariable) in between every statement that is giving me trouble - it does help in pinning down the specific statement that's causing the problem.

    Hope this isn't too simplistic. The other suggestion would be to post the code.

    Gary

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

    Re: More form field headaches

    Stephan,

    Is the document protected (for forms)?
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  4. #4
    Star Lounger
    Join Date
    Dec 2000
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: More form field headaches

    Gary,

    Thanks for your reply. Actually, possibility #1 is what's happening here. I did test this using just one line of code showing a MsgBox. The MsgBox never shows up using either the EntryMacro or ExitMacro *unless* the form fields are protected. Only problem is I don't want the form fields protected.

    So, it looks like I am the victim of yet another Word/Word VBA bug -- the FormField's EntryMacro and ExitMacro won't run unless the form fields are protected. Now, I am racking my brains out trying to get the original functionality I wanted some other way -- updating the contents of fields throughout a document when the user edits one field.

    Any ideas on how to do this?

    (BTW, I almost forgot how much fun Word VBA is after having been away from it for a while.)

    Thanks.

    Stephan

  5. #5
    Star Lounger
    Join Date
    Dec 2000
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: More form field headaches

    No, it isn't protected. Originally, I thought I wanted the form fields to be protected, but later I realized I couldn't do that, because the end-user has to be able to edit the document itself.

    Again, what I'm really trying to do here is have the contents of fields throughout a document (like a COMMENTS field containing an invoice number) change throughout a document when the user changes a form field entry (hence, using the form field's ExitMacro).

    Stephan

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

    Re: More form field headaches

    Stephan,

    Maybe you have to use the ActiveX controls from the Control Toolbar.

    Or you could have something like a button which the user had to click to trigger your macro.

    Alternatively, have your form field in a (small) protected section of the document, with the majority of the document unprotected.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  7. #7
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, BC
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: More form field headaches

    Here are two ideas:
    1. Use the form fields. Protect the document. On exit from the second field, run a macro to update all the fields and unprotect the document. Make sure the user never reprotects the document.
    2. Use ASK fields. Use REF fields wherever the values go in the document. These don't trigger a macro, however, as far as I know, so you'll have to get the user to print preview to update the fields, or click a button that runs an update macro, or ignore them until the document is printed.

  8. #8
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: More form field headaches

    Hi Stephen:

    Depending upon the actual document, you could protect sections of the document so that you could use entry & exit macros. That would still allow editing of non protected sections. However, Wendy's suggestion sounds the best, if it will work for you.

  9. #9
    Star Lounger
    Join Date
    Jan 2001
    Location
    Upstate NY, New York, USA
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: More form field headaches

    I hope you've figured it out but here's one more suggestion - similar to Wendy's. I use form fields and give them a specific bookmark name (eg., "InvoiceNumber"). Then, when I need to reuse that same information later in the document, I simply put a REF "InvoiceNumber" field and the information will appear throughout the document.

    <font color=blue>text</font color=blue>

  10. #10
    Star Lounger
    Join Date
    Jan 2001
    Location
    Upstate NY, New York, USA
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: More form field headaches

    I hope you've figured it out but here's one more suggestion - similar to Wendy's. I use form fields and give them a specific bookmark name (eg., "InvoiceNumber"). Then, when I need to reuse that same information later in the document, I simply put a REF "InvoiceNumber" field and the information will appear throughout the document.

  11. #11
    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: More form field headaches

    Hi stephan,

    Form fields won't work unless the document is protected for forms. As others have already said, this doesn't mean that the entire document has to be protected, just the section that the form field are in. Then, if it is protected, you have to check the little box in each field's properties that says "Calculate on Exit." This has nothing to do with whether an exit macro runs or not, this has to do with whether the reference fields elsewhere in your document get updated with the new information.

    You may want to be using a user form.

    You may want to download and explore the following:
    http://www.addbalance.com/word/download/AskForm.zip (11K)
    http://www.addbalance.com/word/download/UserForm.zip (20K)
    (These are written as tutorials.)

    Other sample forms using form fields:
    http://www.addbalance.com/defense/SPD/paymentV.zip
    http://www.addbalance.com/defense/SPD/spd_exp.zip
    http://www.addbalance.com/defense/SPD/transreq.zip
    (These are simply forms that work. At least one has an unprotected section.)
    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
  •