Home

Cells with line breaks when saving Excel file as a Unicode text using VBA

wcndave
Occasional Visitor

When doing "save as" and selecting unicode, line breaks in cells are handled, the whole thing is wrapped in "" properly.

 

When using vba

 

Set wb = Application.Workbooks.Add
WorkRng.Copy
wb.Worksheets(1).Paste
saveFile = Application.GetSaveAsFilename(fileFilter:="Text Files (*.txt), *.txt")
wb.SaveAs Filename:=saveFile, FileFormat:=xlUnicodeText, CreateBackup:=False
wb.Close

 

It doesn't, each line break is written on a new line in the text file.