Setting the connection string to a QueryTable.refresh

  • Thread starter Thread starter Candyman
  • Start date Start date
C

Candyman

I use code to add new tables, but now I sinply want to refresh the table. So
the connection string has been tested.


'******** Refresh the data **********************************
'On Error GoTo ResetTitles
' With ActiveSheet.QueryTables.add(Connection:=ConnectString,
Destination:=Range(DataTarget), Sql:=mySQL)
' .Refresh BackgroundQuery:=False
' End With
' On Error GoTo 0


What is the syntax for getting the connection string to work with the
refresh? This won't work.

For Each oSheet In Worksheets
For Each QT In oSheet.QueryTables
QT.Refresh Connection:=ConnectString, BackgroundQuery:=False '
Next QT
Next oSheet
 
Back
Top