Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Catch _AfterSave Event & Saved Property Problem ...

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Catch _AfterSave Event & Saved Property Problem ...

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.

--
Regards,
Tom Ogilvy



"Joe HM" wrote in message
ups.com...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Catch _AfterSave Event & Saved Property Problem ...

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Catch _AfterSave Event & Saved Property Problem ...

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Catch _AfterSave Event & Saved Property Problem ...

Joe,

Try setting the Saved property

ThisWorkbook.Saved = True


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Joe HM" wrote in message
ups.com...
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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Catch _AfterSave Event & Saved Property Problem ...

Hello -

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

Thanks,
Joe

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Catch _AfterSave Event & Saved Property Problem ...

if byval is not specified, the default is byref, so explicitly doing that
should change nothing.

--
Regards,
Tom Ogilvy


"Joe HM" wrote in message
ups.com...
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



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Catch _AfterSave Event & Saved Property Problem ...

Hello -

Weird ... that I must have done something else wrong!

Thanks again,
Joe

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I 'catch' a 'delete cells' event Eric Excel Discussion (Misc queries) 2 March 9th 05 07:22 PM
Catch drop event in excel Edi Excel Programming 1 February 20th 05 05:26 PM
How to catch mouse/keyboard event in Office addin Frank King Excel Programming 4 October 13th 03 10:14 PM
Catch Update Linked Cells Event Joe[_23_] Excel Programming 1 August 14th 03 02:39 PM


All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"