Notifications
Clear all
I'm using the code below, but my Do While Application.CalculationState <> xlDone is not working correctly. The macro tries to save the file before the Refresh All is completed.
Please provide a solution.
Sub RefreshAllConnections()
' Refresh all data connections in the workbook
ThisWorkbook.RefreshAll
' Wait for the refresh to complete before continuing
Do While Application.CalculationState <> xlDone
DoEvents
Loop
' Save the workbook after the refresh is complete
ThisWorkbook.Save
' Close the workbook
ThisWorkbook.Close SaveChanges:=False
End Sub
Posted : 28/08/2024 9:07 am
I unchecked "Enable background refresh" for all queries and that solved the problem.
Posted : 30/08/2024 10:53 am