+ Reply to Thread
Results 1 to 3 of 3

Macro to close and re-open a workbook at specific time

  1. #1
    Registered User
    Join Date
    04-09-2013
    Location
    Calgary, Alberta
    MS-Off Ver
    Excel 2010
    Posts
    9

    Macro to close and re-open a workbook at specific time

    Hello,

    I would like to create some code to close an excel file (don't save) and re-open it. The closing and re-opening procedure should occur at a specific time (say midnight) daily. Thanks in advance for your assistance.

  2. #2
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Macro to close and re-open a workbook at specific time

    Take a look at Task Scheduler (control panel, administrative tools)

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Macro to close and re-open a workbook at specific time

    The code would need some sort of host application to contain it; if you close a workbook that contains code it will immediately halt the execution of that code.

    I'd consider placing the code in another spreadsheet, but you'd still be running code nonstop at all other times which isn't super good even with prodigious amounts of DoEvents.

    I'd consider using the Windows Task Scheduler to perform a batch file taskkill, alongside another schedule to launch. I have a few workbooks that open themselves on Mondays, run SQL, and auto-email their self refreshed PivotTables and then self close.

    Or even invoking the Form_Timer property of an empty Access Form which self runs at an interval you command. I use this type of construct for code I need to run very often (every 80 seconds in my case) but without the volatility of continuous processor burden.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

+ 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. Replies: 1
    Last Post: 07-02-2015, 11:06 PM
  2. [SOLVED] Macro to open/close/save workbook
    By JonathanB2 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-14-2014, 10:51 AM
  3. How to open,save and close another workbook from the current workbook using macro?
    By ravikumar00008 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2012, 10:42 AM
  4. Macro to close a workbook after x amount of time when its open read only
    By extremecorvette in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-17-2011, 05:43 PM
  5. Close workbook at specific time
    By rhudgins in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-11-2011, 03:45 PM
  6. Macro to close workbook open in IE?
    By martin.mcgarry in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-05-2010, 02:13 PM
  7. Macro to detect if workbook is open Getting close!
    By LAWDAWG in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-20-2009, 12:26 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