View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Zik Zik is offline
external usenet poster
 
Posts: 1
Default Using Variables for file paths in QueryTables.Add

Hi,
I have the following script for querytable.add, I am trying to use a
variable for the path and file name under the connection property, but
so far I have not been successful in that.
Thanks,

Zik

With ActiveSheet.QueryTables.Add(Connection:= "TEXT;C:\Documents and
Settings\ _
, Destination:=Range("A1"))
.Name = "Viewer"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
.Refresh BackgroundQuery:=False
End With