+ Reply to Thread
Results 1 to 3 of 3

Macro keeps running even after the file that contains it has been closed

  1. #1
    Registered User
    Join Date
    08-27-2013
    Location
    UK
    MS-Off Ver
    Excel 20010
    Posts
    25

    Macro keeps running even after the file that contains it has been closed

    I'm having a bit of a weird issue with a particular spreadsheet. It's used by a lot of people so I've tried to get it to close down after 10 minutes of inactivity, as well as do a couple of other little things (mainly remove any filters that have been applied) before it closes.

    The trouble I'm having is that the timed inactivity loop seems to remain active even after the spreadsheet has closed. When the loop runs out the macro manages to reload the spreadsheet but then produces an error because the variable is blank (presumably since the spreadsheet has been closed).

    I can't work out what's going on. Here's the code in ThisWorkbook:

    Please Login or Register  to view this content.
    and here's what's in a module:

    Please Login or Register  to view this content.
    Any thoughts would be appreciated. Thanks!
    Last edited by davepoth; 11-19-2014 at 09:06 AM.

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Macro keeps running even after the file that contains it has been closed

    Hi,

    In Sub ShutDown(), you must terminated the running timer first, before you launch another timer. So, just add "Call StopTimer" before "AckTime = 10" line.

    Regards
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  3. #3
    Registered User
    Join Date
    08-27-2013
    Location
    UK
    MS-Off Ver
    Excel 20010
    Posts
    25

    Re: Macro keeps running even after the file that contains it has been closed

    Thank you! I'll give that a go, but it certainly looks right now.

+ 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] BeforeClose event not running/working when file is closed through VBA in another file
    By jaimelwilson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2014, 03:43 AM
  2. [SOLVED] stop macro running when workbook has closed
    By nickymac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-07-2013, 12:25 PM
  3. [SOLVED] Run macro x no. of times if file closed for x no. of days.
    By JonathanP in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-06-2012, 05:44 AM
  4. Accessing a closed xls file from a macro
    By Seapeace in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-27-2008, 09:11 AM
  5. [SOLVED] Keeping a macro running after the calling workbook is closed (XL2K)
    By Simon C in forum Excel General
    Replies: 5
    Last Post: 10-25-2005, 01:05 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