Excelfile wants to save before closing

G

Guest

Hi all

I have a File which always asks me to Save before I close, even if I have
saved it 2 seconds before. Is there a possibility to tell excel that it
doesn't need to ask?
Can I just set the Displayalerts to false before closing? I'm afraid that it
would save this state and the next time I open Excel Displayalerts would
still be on false.

Any help is appreciated

Thanks in advance

Carlo
 
G

Guest

You can set displayalerts=false in the before close dialog and Excel won't
remeber this the next time it is opened but this is risky becuase if there is
a genuine need to save before closing the macro will run again and you won't
be alerted.

It is far more likely that something is actually changing in the workbook.
You could try and detect changes you are unaware of by putting something in
the sheet acahnge macro temporarilly.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
msg = "I've changed"
MsgBox (msg)
End Sub

This will alert you and maybe help you track changes you are unaware of.
 
G

Guest

Mike

That is a good solution, may I just recommend that Carlo put the following
in the message box:

Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Target As Range)
MsgBox "Changed at '" & Target.address & " on '" & _
sh.name & "'.", vbokonly,"Change"
End Sub

It may make it easier to pickup.
 
G

Guest

Hi Mike

thanks a lot for your answer.

I'm going to do it with the displayalert, but I'm going to query
if a certain cell has the right state. If it has, nothing needs to
be changed. So I can live with that.
But nevertheless i'm going to try and find out what changes,
I'm quite sure it is a Worksheet Function I wrote which gets
triggered after Save. But I'm having a look at this.

Thanks a lot for your quick answer

Carlo
 
G

Guest

Hi Guys

first of all thx Martin for the addition.

secondly, if I write these lines:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
End Sub

Excel still asks me if I want to save!!?
What do I do wrong?

Thanks for any answer

Carlo
 
G

Guest

What I just found out:

If I debug the value of displayalerts it is always true,
I can't change it in the beforeclose sub, could that be??

Carlo
 

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