H
Hollands Nieuwe
Hello,
I need to import external data in excel daily.
The path and the file change several times.
I already made 2 variables for path and filename.
How do I get them in the querry code in VBA.
see belows part of the total code I use for the script.
these are the variables I want to use. for example I gave them here
the values also
strNamePath = \\PC_TRADE\Documents\Logs\
strNameFile = Unpaid_20111129.txt
strPathFile = \\PC_VAN_TRADERS6\Documents\Adyen Logs
\Unpaid_20111129.txt
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;\\PC_TRADE\Documents\Logs\Unpaid_20111129.txt",
Destination _
:=Range("A3"))
.Name = "Unpaid_20111129"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 2, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
thnx in advance.
Maurice
I need to import external data in excel daily.
The path and the file change several times.
I already made 2 variables for path and filename.
How do I get them in the querry code in VBA.
see belows part of the total code I use for the script.
these are the variables I want to use. for example I gave them here
the values also
strNamePath = \\PC_TRADE\Documents\Logs\
strNameFile = Unpaid_20111129.txt
strPathFile = \\PC_VAN_TRADERS6\Documents\Adyen Logs
\Unpaid_20111129.txt
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;\\PC_TRADE\Documents\Logs\Unpaid_20111129.txt",
Destination _
:=Range("A3"))
.Name = "Unpaid_20111129"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 2, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
thnx in advance.
Maurice