Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Jul 2001
    Location
    Edison, New Jersey, USA
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro Command Failed? (Word 2000)

    I have this statement in a Close macro:
    ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

    It causes a Command Failed msg (4198), but it is right out of the help text.

    I have also tried:
    Documents("Sales.doc").Close SaveChanges:=wdDoNotSaveChanges

    It gets the same error.

    The big picture: The folks are making erroneous changes to a doc by just Closing it and saying Yes to the Save? dialog. I want to protect this way - when they click on the Close Window (upper right-hand X), I send an Input Box asking for a password. If they have the password, I allow the save and close. If they do not have the password, I want to close the document without saving any changes. This last action is what I am getting the above error on. The macro is associated with 'This Document' folder under the Project for this doc as:
    Private Sub Document_Close()

    I also tried the same thing with:
    Sub AutoClose()
    located under the Project for this doc in the 'NewMacros" folder.

    Any ideas? TIA

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Macro Command Failed? (Word 2000)

    To prevent saves when using ActiveDocument.Close, try first telling Word that there are in fact no unsaved changes in the document:

    ActiveDocument.Saved = True

    Hope this does it!

  3. #3
    Star Lounger
    Join Date
    Jul 2001
    Location
    Edison, New Jersey, USA
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro Command Failed? (Word 2000)

    Same error after adding:

    ActiveDocument.Saved = True

    directly before attempting the close with no changes.

    I should also point out that I have been using: WordBasic.DocClose
    to close my docs because I haven't been able to get any VBA-specific code to work . My VBA problems seem to be related only to the 'close' attempts.

  4. #4
    Star Lounger
    Join Date
    Jul 2001
    Location
    Edison, New Jersey, USA
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro Command Failed? (Word 2000)

    FYI, after testing more variations, I have determined that the following works:
    ActiveDocument.Saved = True
    ActiveDocument.ActiveWindow.Close SaveChanges:=wdDoNotSaveChanges

    and

    ActiveDocument.ActiveWindow.Close

    to close the document.

    I do not read where the .ActiveWindow. is required, but it sure seems to be on my system.

Posting Permissions

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