Excel close/save/prompt problem

C

clayton

I have tried every thing I have seen on this site and so far I can't ge
it to do what I want.

I simply want excel, regardless of who is viewing the file, to no
prompt to save changes when closing excel itself or the workbook..
This sound easy enough by putting the following code in thisworkbook:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
Application.EnableEvents = False
ThisWorkbook.Saved = True
End Sub

However.. If I just highlight a few cells and try to close it exce
still prompts me to save.


Here is my complete thisworkbook code:

Private Sub Workbook_Open()
ActiveWindow.DisplayWorkbookTabs = False
Sheets("master").Select
ActiveSheet.ComboBox1.activate
Application.DisplayAlerts = False
Application.EnableEvents = False

End Sub


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
Application.EnableEvents = False
ThisWorkbook.Saved = True
End Sub


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel A
Boolean)
If SaveAsUI = True Then
MsgBox "Only have one copy of this form. Sorry, No exceptions."
Cancel = True
Exit Sub
End If

End Sub




I want to be able to manually save the file myself somehow but no
allow anyone else. And to definatly not prompt to save over my file.

Also, if I use
Application.DisplayAlerts = False
Application.EnableEvents = False


then the following has no effect


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel A
Boolean)
If SaveAsUI = True Then
MsgBox "Only have one copy of this form. Sorry, No exceptions."
Cancel = True
Exit Sub
End If

End Sub


:confused
 
C

clayton

Assuming you wanted me to put it in the Workbook_BeforeClose
(very new to all this)
it did not work for me. If I so much as highlight a cell it will promp
me to save changes when I try to close excel..
 
H

Henry

Clayton,

Sorry, I should have told you to put it in the Workbook_BeforeSave event.

HTH
Henry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top