Kbase P125773: Incorrect characters are displayed when importing text file generated via OUTPUT TO into Microsoft E
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  9/7/2007 |
|
Status: Unverified
FACT(s) (Environment):
Windows
SYMPTOM(s):
Microsoft Excel
ABL procedure exports data contained extended characters to a text file
Text file is imported into an MS Excel spreadsheet via a MS Excel Add-In macro
Extended characters are displayed incorrectly within the spreadsheet
Characters are displayed correctly when the file is opened in Notepad
Characters are displayed properly if the text file is opened in Notepad and re-saved with the Encoding option set to Unicode or UTF-8
File Origin defaults to Windows (ANSI) when importing the text file into Excel manually via the Text Import Wizard
Using the VBA method OpenText to import the text file:
Workbooks.OpenText _
FileName:=MyFile, _
Origin:=xlWindows, _
StartRow:=1, _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=True, _
Semicolon:=False, _
Comma:=False, _
Space:=False, _
Other:=False
CAUSE:
Problem is caused by the Origin setting of VBA OpenText method which imports the file by Windows (ANSI) as the default. There is nothing wrong with the text file generated by Progress.
FIX:
Modify the Origin parameter of the OpenText method so that it is set to 65001 - Unicode (UTF-8) to display the characters correctly in the spreadsheet.
Workbooks.OpenText _
FileName:=MyFile, _
Origin:=65001, _
StartRow:=1, _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=True, _
Semicolon:=False, _
Comma:=False, _
Space:=False, _
Other:=False
Please note that the Origin parameter can only be set to the code page number of the desired code page from Microsoft Office 2003 and later