Hi
I have one query from an external workbook and then I have several other queries that use the External Query
I'm trying to Refresh all Queries in VBA
1st Get the External Data and then from that Refresh All other Queries that are based on that one
Initially I tried Refresh ALL and then Reffresh2 option but neither worked. They refreshed the external query but didnt refresh all other queries in the workbook
I have one query from an external workbook and then I have several other queries that use the External Query
I'm trying to Refresh all Queries in VBA
1st Get the External Data and then from that Refresh All other Queries that are based on that one
Initially I tried Refresh ALL and then Reffresh2 option but neither worked. They refreshed the external query but didnt refresh all other queries in the workbook
VBA Code:
Sub Refresh1()
' Refreshed External Query but didn't Refresh other queries
ActiveWorkbook.RefreshAll
End Sub
VBA Code:
Sub Refresh2()
' Refreshed External Query but didnt Refresh other queries
Dim objConnection, bBackground
For Each objConnection In ThisWorkbook.Connections
bBackground = objConnection.OLEDBConnection.BackgroundQuery
objConnection.OLEDBConnection.BackgroundQuery = False
objConnection.Refresh
objConnection.OLEDBConnection.BackgroundQuery = bBackground
Next
End Sub