Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Posts
    304
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AutoExit macro to clear fields (Word 97)

    Have a document that runs an AutoOpen macro and prompts user to fill in a field. Would like to create a macro that runs upon closing the document that would clear the information they typed from that field. Any ideas? Tried protecting the document, but that caused problems.

    Thanks! - Satiria

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

    Re: AutoExit macro to clear fields (Word 97)

    Satiria,

    Haven't tested this, but maybe something like:

    Dim aField As Field
    For Each aField In ActiveDocument.Fields
    aField.Result = ""
    Next 'aField
    End Sub

    Gary

  3. #3
    3 Star Lounger
    Join Date
    Apr 2001
    Posts
    304
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoExit macro to clear fields (Word 97)

    Thanks Gary for the suggestion. I tried it and it did not do anything unfortunately. I named the macro AutoExit thinking that would prompt it to run upon closing the document - should I have named it something else? Perhaps if you contact me (cgarrick@mcnair.net), I could send you the document and it might make more sense. I know that what I'm asking it to do is quite simple, but because I am not that familiar with Visual Basic, it seems daunting to me.

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoExit macro to clear fields (Word 97)

    AutoExit runs when you close Word, not the document.

    Put the code in this sub of the document object:

    Private Sub Document_Close()

    End Sub
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

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

    Re: AutoExit macro to clear fields (Word 97)

    Hi Kevin:

    Is there an advantage to using Private Sub Document_Close rather than AutoClose?

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoExit macro to clear fields (Word 97)

    Phil,

    They appear to be identical events fired when a doc closes. AutoClose does fire first, though.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

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

    Re: AutoExit macro to clear fields (Word 97)

    Thanks, Kevin. I'm a little behind again in responding. We need the gif meister to come up with a smilie for "a little behind". <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

Posting Permissions

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