I have a query that connects to another Excel spreadsheet. According to everything I've been able to find, the following should reset the connection:
ActiveSheet.QueryTables(1).Connection = Range("Conn_string")
There is data on the sheet, and it does refresh.
Yet: activesheet.querytables.count is ZERO! I cannot set the querytable, because there isn't a query table on the sheet.
MsgBox ActiveWorkbook.Connections("qry_data").ODBCConnection.Connection shows me the current connection string.
ActiveWorkbook.Connections("qry_data").ODBCConnection.Connection = Range("Conn_String") Gives me Run-time error 5: Invalid call or argument.
Any ideas? Should I be pursuing the non-existent Query Table or is there some incantation to set ActiveWorkbook.Connections("qry_data").ODBCConnection.Connection to the desired string.
And yes: Set ActiveWorkbook.Connections("qry_data").ODBCConnection.Connection doesn't work either. It says object required.
Bookmarks