View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
SF SF is offline
external usenet poster
 
Posts: 8
Default Fail to open unicode txt file in excel

Hi Joel,

Thank you very much for your promt advice. I have come up with the code
below but I am still having problem in replacing the C:\PIC\OUTPUT.XLS,
close the worksheet and exit Excel


ActiveWorkbook.SaveAs FileName:="C:\PIC\OUTPUT.xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=True
xlApp.UserControl = False
'Application.DisplayAlerts = False
xlApp.Quit

SF

"Joel" wrote in message
...
I'm not usre but I think the UNICODES look like Binary data. Opening a
File
in Text Mode that contains Binary characters can have problems. When you
open a file in text Mode Basic expects carriage returns and line feed to
be
in the file. Basic has a limitation for the length of a Text String.
Errors
will occur in Basic if the Text String length is exceeeded.

try Opening the file in binary mode.

"SF" wrote:

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