How do I disable save prompt when exiting a sheet?

C

Copter32

I have hyperlinked sheets within a file. When you exit from sheet 2 or 3 or
.... , there is a save file prompt. I do not wih viewers to do this, even
though read only protected, one can still save a copy called "copy of
filemame". Is one able to disable this prompt? Thanks!
 
F

FSt1

hi
you could try this. but be warned....the file will close without saving
changes!
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ActiveWorkbook.Close savechanges:=False
End Sub

regards
FSt1
 
G

Gord Dibben

A file is a workbook which consists of one or more worksheets.

You should not get any message when you switch from one worksheet to another
within a workbook.

Did you mean to say you are closing a workbook?


Gord Dibben MS Excel MVP
 
C

Copter32

Gord -
Yes. In fact it is when you close the workbook, not the worksheet. Sorry
the question wasn't as clear as it should have been. Thanks for your
response. Any additional help will be appreciated. Thanks!
Cop
 
J

JP

You would use some VBA code, placed in the ThisWorkbook module, such
as

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Me.Saved = True
End Sub

This tells Excel that the file is already saved, so do not display the
save prompt.

For implementation assistance, check out http://www.rondebruin.nl/code.htm

HTH,
JP
 
C

Copter32

This really rasies the question of why is the save prompt appearing when you
try to exit when no changes are made. There are no macros that change.
Would an @now formula cause this? This is the only workbook I have on the
system that does this. All others exit directly if no changes have been
made. Thanks to all of you for your valued replies so far.
 
C

Copter32

YEP! Disabled all worksheet calculation dealing with @now() and problem
disappeared. Restructured calculations based on permanent data not on the
ever changing @now and the workbook closeses without the prompt. Thanks all!
 
J

JP

Yes, Now() is a volatile function. You aren't alone, this happens to
me as well. Sometimes Excel just raises the dirty flag for some
unknown reason.


HTH,
JP
 

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