A family of Microsoft word processing software products for creating web, email, and print documents.
Try this;
Sub closenosave()
'
' closenosave Macro
'
'
ActiveWindow.Close (False)
End Sub
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
A family of Microsoft word processing software products for creating web, email, and print documents.
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.
Answer accepted by question author
Try this;
Sub closenosave()
'
' closenosave Macro
'
'
ActiveWindow.Close (False)
End Sub
That's it. "ActiveWindow.Close (False)" works. Thank you.
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.
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.
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.