View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Fail to open unicode txt file in excel

have a look at the 2nd argument to the OpenText method, Origin.
<Help
Origin
Optional Variant. Specifies the origin of the text file. Can be one of the
following XlPlatform constants: xlMacintosh, xlWindows, or xlMSDOS. If this
argument is omitted, the method uses the current setting of the File Origin
option in the Text Import Wizard.
<Help

You can try to this property to 65001 when opening.

NickHK

"SF" wrote in message
...
Hi,

I can mannually import a unicode text file into excel by specifying the

File
origin to be "65001 : Unicode (UTF-8)" but fail to automate the opening of
the same file with the following code.

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet


Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.OpenText "C:\PIC\OUTPUT.TXT" = Excel open the
OUTPUT.TXT file but not display the correct Unicode format

Could someone advice

SF