Setting Workbook Changed Indicator

  • Thread starter Thread starter Jack Gillis
  • Start date Start date
J

Jack Gillis

I need to set whatever indicator or key used by Excel that tells it a
workbook has been changed and prevents it from closing without asking if
I want to save it. Some of my macros make temporary appearance changes
to the workbook that I do not ever want to save and I would like to
reset the indicator so that when click on the 'red X', Excel will close.

I'm not sure if I have made my question clear.

Thank you very much.
 
You could just set the .saved flag to true at the end of your code, but if the
user (you??) actually made changes that need to be saved, you won't be reminded.

Maybe it would be better to save that status, run your code and change the
status back to what it was:

Option Explicit
Sub testme()

Dim mySavedStatus As Boolean

mySavedStatus = ActiveWorkbook.Saved
'your macro here
ActiveCell.Value = 100000
ActiveWorkbook.Saved = mySavedStatus

MsgBox ActiveWorkbook.Saved
End Sub


Activeworkbook.saved = true
is one way of just overriding that flag. (But I'd still be careful with that.)
 
Dave Peterson said:
You could just set the .saved flag to true at the end of your code,
but if the
user (you??) actually made changes that need to be saved, you won't be
reminded.

Maybe it would be better to save that status, run your code and change
the
status back to what it was:

Option Explicit
Sub testme()

Dim mySavedStatus As Boolean

mySavedStatus = ActiveWorkbook.Saved
'your macro here
ActiveCell.Value = 100000
ActiveWorkbook.Saved = mySavedStatus

MsgBox ActiveWorkbook.Saved
End Sub


Activeworkbook.saved = true
is one way of just overriding that flag. (But I'd still be careful
with that.)

Thank you, Dave. That is good advice.

Jack
 
Back
Top