+ Reply to Thread
Results 1 to 4 of 4

Prevent BeforeClose Event from triggering if workbook closes with shutdown timer

  1. #1
    Registered User
    Join Date
    07-24-2015
    Location
    Toledo, OH
    MS-Off Ver
    Microsoft Office 2010
    Posts
    85

    Prevent BeforeClose Event from triggering if workbook closes with shutdown timer

    Hi all,

    I built a workbook that needs to be available to people throughout my office. Obviously, if someone opens it and just leaves it open all day, it becomes an issue for the other employees. In order to avoid this, I put in a shutdown timer macro that will save and close the workbook after 20 minutes.

    I have a rather complex BeforeClose Event set up already. It asks if the user really wants to exit the workbook, then hides every sheet in the workbook except one, clears data from several tables, hides a bunch of form control buttons on the various worksheets that only the SuperAdmin is allowed to use (which only show up if you log in as a SuperAdmin upon opening the workbook), saves the workbook and then closes it.

    Here's the problem: if someone times out in the workbook, I don't want that confirmation box to pop up, because then it will just keep sitting there and waiting for someone to do something to it and the workbook won't close, which defeats the whole point of a shutdown timer in the first place!

    Is there a way to NOT fire the message box portion of the code if the user times out in the workbook? Everything else still needs to be done, but I don't want the message box to appear.

    Here's the code for setting up the shutdown timer (it's in a module):

    Please Login or Register  to view this content.
    Here is the code for the BeforeClose procedure:

    Please Login or Register  to view this content.
    Any advice would be greatly appreciated. Thanks!

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,650

    Re: Prevent BeforeClose Event from triggering if workbook closes with shutdown timer

    How about:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    07-24-2015
    Location
    Toledo, OH
    MS-Off Ver
    Microsoft Office 2010
    Posts
    85

    Re: Prevent BeforeClose Event from triggering if workbook closes with shutdown timer

    That works beautifully. Thank you!

  4. #4
    Registered User
    Join Date
    07-24-2015
    Location
    Toledo, OH
    MS-Off Ver
    Microsoft Office 2010
    Posts
    85

    Re: Prevent BeforeClose Event from triggering if workbook closes with shutdown timer

    I wanted to add an update to this. It did work just fine, but I had to create a bit of a workaround. For some reason, the code was not recognizing the DownTime value, and so it was always acting as if the DownTime value had not been exceeded. So I changed the code for the timer so that when it established the DownTime, it would write that time to a cell on one of the worksheets. Then I had the BeforeClose code read that value instead. Worked like a charm after that!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. BeforeClose Event Help
    By trecie13 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-14-2013, 04:27 PM
  2. Timer Closes ALL Workbooks Instead of Specific Worksheet
    By sbernard in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-26-2013, 01:08 AM
  3. [SOLVED] Prevent change event triggering when clearing contents
    By tone640 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2012, 09:34 AM
  4. "Undo" Workbook BeforeClose event if saving is canceld
    By ctckark1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-05-2011, 06:53 AM
  5. Workbook Open Event not triggering
    By Mike Jerakis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2006, 05:15 PM
  6. [SOLVED] Run-time error '424' in VBA event handler on XL shutdown
    By Mike Jones in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-06-2005, 03:06 PM
  7. [SOLVED] How to get out of BeforeClose event without closing?
    By 42N83W in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-11-2005, 02:06 PM

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