Hi,

I can used variables in the following command ?

With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DSN=Excel Files;DBQ=C:\mypath\myfile.xls") _
, Array(";DefaultDir=C:\mypath") _
, Array(";DriverId=1046;MaxBufferSize=2048;PageTimeout=5;")), Destination:=Range("$A$1")).QueryTable
.CommandText = Array("SELECT DISTINCT `A$`.Field1, `A$`.Field2" & Chr(13) & "" & Chr(10) _
, "FROM `A$` `A$` WHERE `A$`.Field1 = 1")
End With

DBQ and Defaultdir is variables and myfile is selected with Application.GetOpenFilename.

Thanks