+ Reply to Thread
Results 1 to 4 of 4

Why does programmatically closing a workbook break OnTime?

  1. #1
    Registered User
    Join Date
    12-10-2010
    Location
    California
    MS-Off Ver
    Excel all versions from 5.0 (1993) to 365
    Posts
    38

    Why does programmatically closing a workbook break OnTime?

    (also posted to mrexcel.com and StackOverflow)

    Why does programmatically closing a workbook break OnTime?

    This code runs fine:

    Please Login or Register  to view this content.
    Manually close another workbook to fire oApp_WorkbookBeforeClose. MySub executes, as expected.

    But, if instead of manually closing another book, you close another book programmatically, OnTime never runs. oApp_WorkbookBeforeClose does execute, so the OnTime is getting registered. But it never runs.

    Please Login or Register  to view this content.
    oApp_WorkbookBeforeClose runs. But MySub never runs.

    Why doesn't OnTime execute if registered by programmatically closing a workbook? No code is running in the book that's closing. OnTime works no problem with other events (eg programmatically opening a workbook). Somehow, closing a workbook programmatically breaks OnTime.
    Last edited by johnywhy; 07-07-2021 at 07:21 AM. Reason: added external link

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,342

    Re: Why does programmatically closing a workbook break OnTime?

    (also posted to excelbanter.com and mrexcel.com)
    Thank you for telling us, however our rules stipulate that you provide LINKS to those cross posts. Please do this now.

    No help to be offered until this request has been actioned.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    12-10-2010
    Location
    California
    MS-Off Ver
    Excel all versions from 5.0 (1993) to 365
    Posts
    38

    Re: Why does programmatically closing a workbook break OnTime?

    Quote Originally Posted by AliGW View Post
    provide LINKS to those cross posts.
    Done, thx.
    excelbanter.com isn't posted yet.
    Last edited by johnywhy; 07-06-2021 at 09:43 AM.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,342

    Re: Why does programmatically closing a workbook break OnTime?

    Bump: the OP still requires help with the original query.
    Last edited by AliGW; 07-07-2021 at 10:46 AM.

+ 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. [SOLVED] Cancelling multiple Application.OnTime events when closing workbook problem
    By anthgav in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-04-2019, 04:47 AM
  2. Excel 2013 not closing after closing workbook
    By SBennett212 in forum Excel General
    Replies: 4
    Last Post: 04-04-2015, 11:07 AM
  3. Creating new workbook, saving as csv and then closing - but closing always fails.
    By ella626 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-28-2014, 10:05 PM
  4. [SOLVED] Application.OnTime won't work for my workbook :(
    By BYizz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-02-2013, 11:51 AM
  5. Close Workbook with Application.OnTime
    By dylanemcgregor in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-30-2009, 11:52 AM
  6. [SOLVED] Disabling VBE Break on All Errors Programmatically with DAO SetOpt
    By Jsadleir in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-19-2006, 10:40 PM
  7. Stopping Application OnTIme when closing a workbook
    By L2B in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2005, 10:20 AM

Tags for this Thread

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