• More form field headaches

    Author
    Topic
    #351939

    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.

    Viewing 4 reply threads
    Author
    Replies
    • #510608

      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

      • #510621

        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

    • #510616

      Stephan,

      Is the document protected (for forms)?

      • #510625

        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

        • #510628

          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.

          • #510633

            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.

            • #510682

              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.

    • #511052

      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.

      text

    • #511053

      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.

    • #511832

      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%5B/url%5D (11K)
      http://www.addbalance.com/word/download/UserForm.zip%5B/url%5D (20K)
      (These are written as tutorials.)

      Other sample forms using form fields:
      http://www.addbalance.com/defense/SPD/paymentV.zip%5B/url%5D
      http://www.addbalance.com/defense/SPD/spd_exp.zip%5B/url%5D
      http://www.addbalance.com/defense/SPD/transreq.zip%5B/url%5D
      (These are simply forms that work. At least one has an unprotected section.)

    Viewing 4 reply threads
    Reply To: More form field headaches

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

    Your information: