1

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!"
Natashah
  • 9
  • 1
  • hi, interesting, not sure if this might be of interest https://superuser.com/questions/349882/how-to-avoid-double-quotes-when-saving-excel-file-as-unicode – jspcal Dec 10 '21 at 01:35
  • Hi, thnks for the answer. at least give me idea why this is happens. seems there is no perfect solution for this? hm. – Natashah Dec 10 '21 at 01:56

0 Answers0