Guest_imported
New member
- Jan 1, 1970
- 0
I'm trying to import a textfile into Excel. I´ve made a variable with a path in it named SelectedFile but it dosn't import the file. I,ve tested the SelectedFile and it does contain a path. If i replace the "TEXT;SelectedFile" with "TEXT;C:\Textfile" it does work. So What am I doing wrong
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;SelectedFile" _
, Destination:=Range("A1")
.Name = "vika"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = False
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(8, 5, 8, 8, 8, 5, 8, 7, 1, 9, 5, 5, 5)
.Refresh BackgroundQuery:=False
End With
Thanks in advance
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;SelectedFile" _
, Destination:=Range("A1")
.Name = "vika"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = False
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(8, 5, 8, 8, 8, 5, 8, 7, 1, 9, 5, 5, 5)
.Refresh BackgroundQuery:=False
End With
Thanks in advance