vbid
07-04-2017, 07:01 PM
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\***x\Desktop\***\***.-2016.txt" _
, Destination:=Range("$A$1"))
.CommandType = 0
.Name = " ***.-2016_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(31, 5, 17, 22, 16, 18, 17)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Thank you readers for helping me with this. Basically i have to loop this code to convert multiple text files into excel and save the file. I currently do not know how to loop this code but the files i want to convert all have ***.-2016.txt in its file name. I also do not know how to save these files automatically and convert the file name to something that i would require
"TEXT;C:\Users\***x\Desktop\***\***.-2016.txt" _
, Destination:=Range("$A$1"))
.CommandType = 0
.Name = " ***.-2016_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(31, 5, 17, 22, 16, 18, 17)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Thank you readers for helping me with this. Basically i have to loop this code to convert multiple text files into excel and save the file. I currently do not know how to loop this code but the files i want to convert all have ***.-2016.txt in its file name. I also do not know how to save these files automatically and convert the file name to something that i would require