+ Reply to Thread
Results 1 to 8 of 8

Catch _AfterSave Event & Saved Property Problem ...

  1. #1
    Joe HM
    Guest

    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. #2
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #3
    Joe HM
    Guest

    Re: 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. #4
    Joe HM
    Guest

    Re: 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. #5
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #6
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >




  7. #7
    Joe HM
    Guest

    Re: 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


  8. #8
    Joe HM
    Guest

    Re: Catch _AfterSave Event & Saved Property Problem ...

    Hello -

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

    Thanks again,
    Joe


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1