+ Reply to Thread
Results 1 to 3 of 3

Windows task scheduler to automatically open(then close) an excel workbook

  1. #1
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Windows task scheduler to automatically open(then close) an excel workbook

    I want to run a routine at a specific time daily. I tried windows task scheduler by selecting the file in the folder but at the scheduled time a popup asked me "how do you want to open this file" which defeats the purpose of the automation. Does anyone know how to suppress this alert or any other way to accomplish what I want to do? Any help appreciated!
    Last edited by aprildu; 11-08-2018 at 09:51 PM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Windows task scheduler to automatically open(then close) an excel workbook

    As you fill out the task when it comes to the part for action, select "Run a Program" then fill in:

    "Full Path to Excel Executable" 'Full Path to Spreadsheet to open"

    For example on my machine the executable is in C:\Program Files (x86)\Microsoft Office\root\Office16 so I enter:

    "C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE" "C:\Users\dflak\Scripts\DPR Thursday.xlsm"

    When entered as the whole line, the Task Scheduler will detect that you are passing an argument to Excel and ask if you want to separate it. Answer Yes.

    This program opens the file DPR Thursday.xlsm.

    The task scheduler can open a file, but it can't run a macro. So I arrange it so the task scheduler opens the script (which has code to run automatically on open) and the script runs a macro in the target spreadsheet. I have two directories: one to hold the scripts and a parallel directory to hold the target workbooks.

    http://www.utteraccess.com/wiki/Schedule_a_Macro_to_Run

    Copy the action line in the script into the action line in the task scheduler.
    Last edited by dflak; 11-15-2018 at 03:22 PM.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Windows task scheduler to automatically open(then close) an excel workbook

    Thank you@dflak.

    I tried vbscript and it works in the folder (double click the file) but the popup still shows when I tried to run it in the scheduler. I also tried the combination of batch file (combined with vbscript). It also works in the folder but it doesn't work either in the scheduler, although the popup didn't show, instead I noticed flashing (looks like working but nothing happens).

    And I think it worked when I first tried somehow it stopped working after two days. Don't know why.

    1. Vbscript (file name mymacro.vbs) - when in the folder it works. But in scheduler the popup shows up.
    Please Login or Register  to view this content.
    2. Batch (combined with vbscript):
    vbscript (file name script.vbs)
    Please Login or Register  to view this content.
    And batch (file name: runit.bat) - when click runit.bat in the folder it works. In scheduler it only flashes but the macros are not run.
    Please Login or Register  to view this content.
    Last edited by aprildu; 11-16-2018 at 12:00 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. Open Excel workbook and run macro using Windows task scheduler
    By MilroyD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2013, 01:17 PM
  2. Windows Task Scheduler, Run Macro.
    By JapanDave in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-03-2013, 03:02 PM
  3. Run Excel and macro using Windows Task Scheduler
    By MilroyD in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-09-2013, 11:24 PM
  4. opening ppt via excel vba breaks when scheduled via windows task scheduler
    By kisa500 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-21-2013, 07:25 PM
  5. Windows Task Scheduler Question
    By tekman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2008, 05:00 PM
  6. [SOLVED] Use Task Scheduler to automatically run Excel workbook
    By John Hazel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-22-2006, 09:10 AM
  7. [SOLVED] Setting a Windows Scheduler Task via VB !
    By RAFAAJ2000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-29-2005, 03:05 PM
  8. [SOLVED] Detect Excel was started with Windows Task Scheduler
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-01-2005, 08:06 AM

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