+ Reply to Thread
Results 1 to 5 of 5

Excel VBA Script Crashes When Refreshing Power Queries Using Task Scheduler

  1. #1
    Registered User
    Join Date
    03-05-2011
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    84

    Excel VBA Script Crashes When Refreshing Power Queries Using Task Scheduler

    I have an xlsm file with a macro that on open, it will launch a Master xlsx of my choice, refresh all the Power Queries (20+ queries), save the Master file and quit excel. The macro file is 20k and the master file is 2MB.

    If I open the xlsm manually, the queries all refresh as normal in under 30 seconds. However if I use task scheduler or any windows automation software to open that xlsm, excel goes non responsive and i have to force quit.

    Anyone experience anything like this before? This same code works on all other PQ files task scheduler refreshes and those range from 10MB-20MB, however have far less queries to refresh.

    Here is the VBA code I'm using.
    Please Login or Register  to view this content.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Excel VBA Script Crashes When Refreshing Power Queries Using Task Scheduler

    Hey Buddy,

    Power Query only works on Excel 2010, 2013 and 2016. Your profile says you are trying to do this with 2003. That would be a problem. Which version are you using? Is your profile correct?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    03-05-2011
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    84

    Re: Excel VBA Script Crashes When Refreshing Power Queries Using Task Scheduler

    Hi,
    Profile is old. I am using excel 2016 64 bit

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Excel VBA Script Crashes When Refreshing Power Queries Using Task Scheduler

    Because you are going to the OS to do stuff, I'd put a bunch of "DoEvents" in your code. The DoEvents wait until the OS comes back to Excel before sending more commands. See it that helps.

  5. #5
    Registered User
    Join Date
    03-05-2011
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    84

    Re: Excel VBA Script Crashes When Refreshing Power Queries Using Task Scheduler

    Quote Originally Posted by MarvinP View Post
    Because you are going to the OS to do stuff, I'd put a bunch of "DoEvents" in your code. The DoEvents wait until the OS comes back to Excel before sending more commands. See it that helps.
    Im guessing the queries are causing the crash so I would need to separate every query call rather than refresh all? I know a little code but mostly pieced this code together from forums a year ago.

+ 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 file using Task Scheduler as Read-Only
    By johncassell in forum Excel General
    Replies: 3
    Last Post: 07-17-2015, 11:42 AM
  2. Task Scheduler Stopped Working - Excel
    By profector in forum Microsoft Windows Help
    Replies: 2
    Last Post: 01-28-2014, 11:11 AM
  3. Running Excel from task scheduler. Scheduler doesn't end
    By tony h in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-31-2013, 09:49 PM
  4. 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
  5. windows task scheduler VBS script to run macro
    By els050676 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-16-2013, 09:13 AM
  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] 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