Excel 2000: File format of Unicode text files

R

Rolf Keller

In Excel it is possible to save a worksheet as 'Unicode text'.

Is there a description of the file format of these unicode text files?

The problem is that there are some quotes (") added, if the cells content e.g. a line feed or quotes. So there may be some additional cases, where unexpected content is added by Excel and this would be very helpful to know.

Thanks
 
J

Jim Rech

I don't think MS has documented their file format publicly.

Your choices may be to do the experimenting yourself to deduce their format,
or to use a macro to create the Unicode text file.

Here's a macro that creates a Unicode file without any quotes. Tweak as
needed.

Sub MakeTabDelimUnicodeFile()
Dim SrcRg As Range
Dim CurrRow As Range
Dim CurrCell As Range
Dim CurrTextStr As String
Dim ListSep As String
Dim FName As Variant
FName = Application.GetSaveAsFilename("", "Txt File (*.txt), *.txt")
If FName <> False Then
ListSep = StrConv(vbTab, vbUnicode)
If Selection.Cells.Count > 1 Then
Set SrcRg = Selection
Else
Set SrcRg = ActiveSheet.UsedRange
End If
Open FName For Output As #1
For Each CurrRow In SrcRg.Rows
CurrTextStr = ""
For Each CurrCell In CurrRow.Cells
CurrTextStr = CurrTextStr & StrConv(CurrCell.Value,
vbUnicode) & ListSep
Next
While Right(CurrTextStr, 1) = ListSep
CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)
Wend
Print #1, CurrTextStr
Next
Close #1
End If
End Sub
 
Top