ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Variables for file paths in QueryTables.Add (https://www.excelbanter.com/excel-programming/368275-using-variables-file-paths-querytables-add.html)

Zik

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



All times are GMT +1. The time now is 04:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com