this is how I convert txt to excel and convert back excel to txt. I want to put all the things in column A in excel and need to maintain the format.
the format seems okay when txt convert to excel. but when I change it back to txt, some of the line add up the symbol " usually its appear at infront and at the back of the line.
here is the code : txt to excel
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & txtFileNameAndPath _
, Destination:=Worksheets(fname).Range("$A$1"))
.Name = "ImportingFileName"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1)
.Refresh BackgroundQuery:=False
End With
here is the code I save excel to txt back.
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Filename:= _
"\\natashah\DA_reports\oneSAP\IPTest\" & fname, FileFormat:=xlText, _
CreateBackup:=False
Application.DisplayAlerts = True
MsgBox "Your file updated and saved!"