Share via

Power Query does not load in time when using Task Scheduler to perform a Data Refresh

Anonymous
2018-04-20T02:02:59+00:00

When I launch my task, this is the error I get in Excel:

This seems to be because the Power Query add-on hasn't fully loaded yet. This is my assumption for two reasons, #1, when I hit debug I can push "run" and it will finish the macro without issue (pushing debug seems to allow Excel to finish loading the add-on).  #2, I can see in the ribbon that the Power Query section isn't there when the error pops up, but it is there after I push debug.

I have also tried adding a delay, but the delay seems to also delay the add-on being loaded as well

Below is my code, any help is going to be great!

Thanks,

Private Sub Workbook_Open()

'Application.Wait Now + #12:00:30AM#

Application.DisplayAlerts = False

ActiveWorkbook.RefreshAll

ActiveSheet.Copy

    With ActiveSheet.UsedRange

         .Copy

         .PasteSpecial xlValues

         .PasteSpecial xlFormats

    End With

    Application.CutCopyMode = False

    ActiveWorkbook.SaveAs "C:\TEST"

    ActiveWorkbook.Close False

    Application.Quit

End Sub

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2018-04-21T17:20:01+00:00

    Problem solved.  No need to answer! :)

    Was this answer helpful?

    0 comments No comments