Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Apr 2010
    Location
    Los Gatos CA
    Posts
    376
    Thanks
    52
    Thanked 12 Times in 11 Posts

    Need help with small Word 2002 macro

    I am using Word 2002, it's good enough, later versions are just obese. There are times when I have worked on a file and I want to save the changes and close the file without any "Save?" prompt. So I have a macro assigned to ALT+/, saves and closes without any input: it works. There are other times when I simply want to close the file without saving the changes. So I recorded the actions: ALT+F C: TAB to highlight NO: ALT+F X. At this point Word closes, a pop-up asks if I want to save the macro and I click Yes. When I try to close a file this way I still get a pop-up asking "Do you want to save the changes". So the action of tabbing to 'No' is not being recorded. And this is the macro:

    Sub Discard()
    '
    ' Discard Macro
    ' Macro recorded 6/27/2014
    '
    ActiveDocument.Close
    Application.Quit

    End Sub


    Can anyone suggest a fix? I'm sure it's simple, but not as simple as I am.

    Thanks,

    David

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,435
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    David,

    Add: Application.DisplayAlerts = False
    before the ActiveDocument Close

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    All you need is:
    Code:
    Sub Discard()
    ActiveDocument.Saved = True
    End Sub
    You could even reduce that to a single line:
    Code:
    Sub Discard(): ActiveDocument.Saved = True: End Sub
    Is that small enough?
    Last edited by macropod; 2014-06-28 at 17:23.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  4. #4
    3 Star Lounger
    Join Date
    Apr 2010
    Location
    Los Gatos CA
    Posts
    376
    Thanks
    52
    Thanked 12 Times in 11 Posts
    Many thanks. I was sure there was a simple solution, both of these are simple enough even for me to grasp!

    David

  5. #5
    New Lounger
    Join Date
    Jan 2014
    Posts
    6
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Belated assistance re: Word macros

    It's nice to hear about someone else who has deliberately stuck with Word 2002 through the years. I've done the same, and for the same reasons: I still feel that a person who has mastered most of Word 2002 could pretty nearly conquer the universe with it. Also, I just know I can't hack those "ribbons" and the goofed-up menus in later versions of Word; and finally, I hate the way all that newer stuff eats up the screen real estate that would otherwise be showing my document.
    Anyway, I will go ahead and throw in my two possible half-baked, kid-stuff, no-guarantee solutions, but it looks like some other memebers of the WS Forum community who are a whole lot snappier than I am about Word macros have already come to the rescue.
    One possibility would be to assign a custom keystroke combination to the "Close" menu/command, and then feed that to the macro at the appropriate step in the sequence, and see if it sticks. Probably not, but worth a try.
    Another try might be the little-known "Close All" menu/command, which is effected by holding down the Shift key when you click on the "File" menu. When you do that, a new, 'nother menu item shows up that wasn't there before in the drop down "File" menu, an option named "Close All," which when selected slams shut all the documents you have open --- that is, if they've previously, at some point, been saved. I'm not sure it will do the trick you're hoping to accomplish, but it always seemed like a particularly potent document shut-down, and I'm wondering if it might override some of the "Are you sure you want to do this" catches and safeguards that ordinarily pop up on your way to closing a doc. Give it a whirl, build it into a macro, and see if that little stratagem works.
    Probably all the above is redundant, inasmuch as the other posted solutions sound like serious weapons-grade macro paraphernalia, but, well . . . just trying to help.
    Good luck.
    Last edited by TechnoTinker; 2014-07-03 at 08:48.

Posting Permissions

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