Share via

Macro: push the "don't save" button?

Anonymous
2013-08-20T18:57:01+00:00

I need help re-writing a macro.  All of a sudden Word 2011 has started ignoring  some, but not all, of my longstanding and well-used macros.  One such is my “closenosave.”  With this macro, I instruct Word to close the active window without saving it.  Manually, the way this works is that, when the “close” command is entered, a dialog box opens asking me if I want to save the document.  I want the macro to click on the radio button “Don’t save.”  But the dialog box opens at varying locations on the desktop, and the macro cannot find the “Don’t save” button.

Years ago someone told me how to get the macro to find the "Don’t save” button, but the macro has been working well for a long time, and I do not have that instruction any more.

Does anyone know how to get a macro to activate “Don’t save” in the dialog box?  TIA

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Bob Jones AKA CyberTaz MVP 436K Reputation points
2013-08-20T22:12:51+00:00

Try this;

Sub closenosave()

'

' closenosave Macro

'

'

    ActiveWindow.Close (False)

End Sub

Was this answer helpful?

0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2013-08-21T15:56:42+00:00

    That's it.  "ActiveWindow.Close (False)" works.  Thank you.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-08-20T22:07:58+00:00

    The VBA command to close without saving is:

    ActiveDocument.Close Word.wdDoNotSaveChanges

    I don't know what you are referring to with buttons and dialogs... I guess you must have a custom user form.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-08-20T19:50:17+00:00

    Here is the text that I get when I record my macro using Command + W and then D:

    Sub closenosave()

    '

    ' closenosave Macro

    '

    '

    ActiveDocument.Close

    End Sub

    Its only differences from yours are the capitalization and an extra apostrophe.   I experimented with deleting one of the apostrophes, but it made no difference in the operation of the macro.

    I was not aware of Command +W and then D.  That is useful.  But I would like to get back to my former macro, because it is custom now and ever so slightly faster.

    Was this answer helpful?

    0 comments No comments
  4. Bob Jones AKA CyberTaz MVP 436K Reputation points
    2013-08-20T19:21:22+00:00

    I'm not much of a programmer so I can't tell you how to 'fix' the macro, especially without seeing the code as it is.

    If this is all it's intended to do, though, you really don't need a macro -- just type Command+W followed by D to close a document without saving.

    Was this answer helpful?

    0 comments No comments