hi,
I have the following code which is updating the connection held for all querytables in my worksheet.
This works fine however I also want to automatically get the querytabke to refresh - ie in Excel the user goes to Data>Connections> and presses the refresh button. Is there a way to access this refresh method through VBA code. I am thinking something along the lines of
Worksheet.QueryTables.Item(itemcount).Connection.Refresh but this doesn't work
For Each Worksheet In ThisWorkbook.Worksheets
itemcount = 0
For Each Item In Worksheet.QueryTables
itemcount = itemcount + 1
Worksheet.QueryTables.Item(itemcount).Connection = SQLConn
Next
Next
Any suggestions?
I have the following code which is updating the connection held for all querytables in my worksheet.
This works fine however I also want to automatically get the querytabke to refresh - ie in Excel the user goes to Data>Connections> and presses the refresh button. Is there a way to access this refresh method through VBA code. I am thinking something along the lines of
Worksheet.QueryTables.Item(itemcount).Connection.Refresh but this doesn't work
For Each Worksheet In ThisWorkbook.Worksheets
itemcount = 0
For Each Item In Worksheet.QueryTables
itemcount = itemcount + 1
Worksheet.QueryTables.Item(itemcount).Connection = SQLConn
Next
Next
Any suggestions?