Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Nov 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form Fields Lose Exit Macros?

    I was testing Word 2000 today, and discovered a problem that occurs in Word 2000 and Word 97 SR-2. I've recreated the problem in as simple an environment as possible:

    I have a Word document, protected for forms, with two Checkbox formfields. In ThisDocument, I have the following code:

    Public Sub box1()
    MsgBox "That was box1"
    End Sub

    Public Sub box2()
    MsgBox "That was box2"
    End Sub

    For Check1, I set box1 as its exit macro. (Double click the field, choose 'box1' in the Run Macro On Exit drop down list). For Check2, I set box2 as its exit macro.

    I protected the document for forms, and when I tab between the two checkbox formfields, the message boxes appear as expected.

    I then send the form to my co-worker (or even to myself) using Word's "Send To" menu item:
    Send To... Routing Recipient... (in WD97 and WD2000),
    Send To... Mail Recipient... (in WD97), or
    Send To... Mail Recipient (as attachment) (in WD2000).

    Close Word. Open the newly received message. The exit macros don't run when I tab between the check boxes. Further investigation shows that the macros are still attached to the document, but are no longer attached to the form fields.

    Can any of you replicate this problem? I've attached my original, functional, two check box document, but I can't get it to work once it's been mailed from within Word.

    Is this a bug?

    Travis
    Attached Files Attached Files

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

    Re: Form Fields Lose Exit Macros?

    Hi Travis,

    Try putting the code into a standard module, rather than ThisDocument - ThisDocument is a special private module that's used for event procedures such as Document_New. (You can get away with putting regular Subs into this module, but probably only if there is a document event procedure in there too.)

    I was able to reproduce your problem - not sure why it happens but I am sure it has to do with the code being in ThisDocument.

    Gary

  3. #3
    New Lounger
    Join Date
    Nov 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Fields Lose Exit Macros?

    No luck, at least in WD97. I'll try WD2000 later today.

    To test your suggestion, with the same form I attached earlier in this thread, I added a new module ("Module1"), and cut and pasted the code from ThisDocument to Module1.

    As before, it works in the document (even after closing and re-opening Word), but a mail recipient (or routing slip recipient) still receives the Word document with the formfields' exit macros set to nothing. It's also worth noting that the macros ('box1' and 'box2') aren't selectable by the recipient -- they're Public Subs in Module1, but don't show up in the formfield exit macro drop down box.

    Very odd.

    Travis

  4. #4
    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 Lose Exit Macros?

    I was not able to reproduce your problem. Note that I did not put anything in "ThisDocument."

    I didn't use the exact code you did but it shouldn't make a difference. The code I used was:

    Sub box1()
    MsgBox "This is Box 1"
    End Sub
    Sub box2()
    MsgBox "This is Box 2"
    End Sub


    I'm attaching my document, together with a zipped copy of the document (because edges of Word documents sometimes seem to get scrambled over the Internet).

    Hope this contribution helps.
    Charles Kyle Kenyon
    Madison, Wisconsin

  5. #5
    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 Lose Exit Macros?

    <img src=/S/threadhead.gif border=0 alt=threadhead width=28 height=31> I suppose I could attach the files. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Looks like I can only attach one file so you get the Word doc.
    Attached Files Attached Files
    Charles Kyle Kenyon
    Madison, Wisconsin

  6. #6
    New Lounger
    Join Date
    Nov 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Fields Lose Exit Macros?

    I downloaded the document you attached, opened it in Word 97, and the macros work.

    I then chose "File" > "Send To" > "Mail Recipient" and sent it to myself.

    When I opened the 'received' document from my inbox, the exit macros no longer functioned. I saved the attachment to my desktop (drag and drop from my e-mail) and opened it from there; the exit macros also don't fire off.

    When I unprotect the document, the properties of the check boxes show no attached exit macros, even though they were there before I "Send To"ed the document.

    My testing the last few days has shown the following. "OK" means that the exit macros fired off when the recipient opened the form and tabbed out of the check box. "<font color=red>NO</font color=red>" means that the exit macros didn't fire off (and were no longer listed in the form field properties drop down list, even though they were included in ThisDocument.)

    <table border=1><td></td><td>.DOC file</td><td>.DOT file</td><td>Sent Word 2000 to Word 2000</td><td>Mail (as attachment)</td><td>OK</td><td>OK</td><td>Routing Slip</td><td><font color=red>NO</font color=red></td><td>OK</td><td>Sent Word 97 to Word 97</td><td>Mail (as attachment)</td><td><font color=red>NO</font color=red></td><td>OK</td><td>Routing Slip</td><td><font color=red>NO</font color=red></td><td>OK</td><td>Sent Word 2000 to Word 97</td><td>Mail (as attachment)</td><td>OK</td><td>OK</td><td>Routing Slip</td><td><font color=red>NO</font color=red></td><td>OK</td><td>Sent Word 97 to Word 2000</td><td>Mail (as attachment)</td><td><font color=red>NO</font color=red></td><td>OK</td><td>Routing Slip</td><td><font color=red>NO</font color=red></td><td>OK</td></table>

    Thanks for your help so far. Like some other Word bugs I've encountered over the last few years, this remains mysterious.

Posting Permissions

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