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.
Option Explicit

Public Function GetPath() As String
    Application.FileDialog(msoFileDialogOpen).Show
        If Application.FileDialog(msoFileDialogOpen).SelectedItems.Count > 0 Then
        GetPath = Application.FileDialog(msoFileDialogOpen).SelectedItems(1)
    End If
End Function

Public Sub Load_DLY_Path()
    Range("Path_DLY").Value = GetPath()
End Sub


Public Sub Main()
    Dim strDailyscrape_Path As String
    Dim wbDailyscrape As Workbook
    Dim DebugMode As Boolean
    strDailyscrape_Path = Range("Path_DLY").Value
    DebugMode = Range("DebugMode").Value


    Set wbDailyscrape = Workbooks.Open(strDailyscrape_Path)

    wbDailyscrape.RefreshAll
    Application.CalculateUntilAsyncQueriesDone


    If DebugMode Then MsgBox ("Daily Scrape updated successfully!")

 wbDailyscrape.Save


    Application.DisplayAlerts = False
    wbDailyscrape.Close (True)
    Application.DisplayAlerts = True
    If DebugMode Then MsgBox ("Done!")
    Application.Quit
End Sub