Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27201

[RESOLVED] Macro to close workbook without saving

$
0
0
I have in Module1:

Code:

Sub Auto_Open()
    If vbYes <> MsgBox("Message", vbYesNo + vbExclamation, "User Agreement Disclaimer") Then
        ThisWorkbook.Close False
    End If
End Sub

I am also using a tricky method to force users to enable macros.
Found here: http://www.vbaexpress.com/kb/getarticle.php?kb_id=379

When a user enables macros several sheets become visible which in way has changed the file. Once the user has enable macros my "User Agreement Disclaimer" opens. If someone chooses cancel, the workbook closes but because of the fact that sheets have become visible they are asked if they want to save changes. If at this point they choose cancel the workbook does not close and they now have access to it without agreeing to the disclaimer.

Is there a way using the first bit of code to close the workbook without saving? Thanks!

John

Viewing all articles
Browse latest Browse all 27201

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>