Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jun 2008
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reversing Before_Close Macro (O2000SR1)

    I create and destroy my toolbar every time the workbook is opened/closed as the folks on this site have suggested. Works very well, except if someone clicks "cancel" when they are asked if they want to save their changes. Then the toolbar is long gone and the workbook still open. How to undo the Before_Close macro if they cancel?

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reversing Before_Close Macro (O2000SR1)

    The only way that I know of is to display your own Msgbox to ask that question and don't remove the toolbar if they click Cancel. Then your code should do the save or reset the dirty flag and set DisplayAlerts=False.
    Legare Coleman

  3. #3
    New Lounger
    Join Date
    Jun 2008
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reversing Before_Close Macro (O2000SR1)

    Do you mean that I would highjack the normal File/Save or SaveAs etc.? Build my own main toolbar? Seems like a lot of work to recreate all that. And a little dangerous if they open multiple workbooks and so forth. Too bad there isn't a "After_Close" or "Before_Close_But_After_Cancel_Option" event.

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reversing Before_Close Macro (O2000SR1)

    No, you do not need to hijack the FileSave or FileSaveAs.

    In the BeforeClose event you can look at the file dirty flag and if it is set you display a Msgbox asking if they want to save changes. If they click Cancel, you just cancel the Close event using the Cancel parameter that is passed to the event routine before you remove your toolbar. If they say yes, you do a file save, then remove your toolbar, set the dirty flag to false and exit. If the file dirty flag is not set, then you can just remove your toolbar and exit.
    Legare Coleman

  5. #5
    New Lounger
    Join Date
    Jun 2008
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reversing Before_Close Macro (O2000SR1)

    Ah, I see. That should work. Thanks.

Posting Permissions

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