Catch _AfterSave Event & Saved Property Problem ...

  • Thread starter Thread starter Joe HM
  • Start date Start date
J

Joe HM

Hello -

I found the _BeforeSave handler but I was wondering if there is a
AfterSave handler? I would like to enable some things on my worksheet
if a read-only file was successfully saved as something else. How can
I catch that? I saw that one of the arguments of _BeforeSave deals
with save as and anoter with cancel. The save as makes sense but I
somehow thought that I could catch a Cancel Button push with the second
argument. I guess that's not the way it works because it is a
_BeforeSave handler.

Another thing that I cannot seem to get to work is the Saved property.
I disable some things on one of my sheets if the file was opened in
read-only. I figured that out thanks to some great people here. It
calls a function with the Application.OnTime in the _Open() handler.
So I disable a few things but now Excel thinks that I changed stuff
that needs to be saved! I tried to set ThisWorkbook.Saved = True but
it still prompts me to save the file even though I actually have not
really changed anything.

Thanks so much for you help!
Joe
 
Cancel is to cancel the action that triggered the Save.

If you made changes to the workbook, then how can you say you didn't.

You can use the beforesave to control things

in the before save,

' cancel the user's save
cancel = False
' perform actions
Application.EnableEvents = False
sName = lcase(Thisworkbook.FullName)
fName = application.GetSaveAsFilename
thisworkbook.Save fName
if sName <> lcase(fName) then
' perform actions
End if
Application.EnableEvents = True

End Sub

The above pseudo code may give you some ideas.
 
Hello -

For some reason I have now two SaveAs windows in a row pop up. How can
I simply determine whether my file has successfully been saves as?

I do a few changes that should not be saved. That's why I tried to
clear whatever Excel thought I changed. Everything after that should
be considered a change. Is there a way to check for that?

Thanks!
Joe
 
Hello -

I actually figured it out ... I guess. The function interface that the
VB Editor generated did not have the Cancel as byref. I changed that
and set it to true to cancel the action. Then I just open up the Save
As dialog and check wheter it returned False or not.

The only problem I have not fixed yet is how to clear the "changed"
buffer or whatever that is.

Thanks,
Joe
 
Joe,

Try setting the Saved property

ThisWorkbook.Saved = True


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
if byval is not specified, the default is byref, so explicitly doing that
should change nothing.
 
Hello -

Yeah ... I tried that but it still prompts me even though I have not
changed anything!

Thanks,
Joe
 

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

Back
Top