How to open UTF-8 files with Workbooks.OpenText

G

Guest

Hello,

We've written an Excel macro that opens a text files as a workbook. We use
the Workbooks.OpenText method to accomplish this. It has been working fine,
but we just recently noticed that if we open try to open a text file as a
workbook that is in UTF-8 character set and includes some Extended Latin
characters (which are two bytes in UTF-8) it splits these two-byte Extended
Latin characters into two seperate characters as the macro creates the Excel
workbook. We noticed that this problem is because Excel by default is
treating the text file as an ANSI file although it is UTF-8, because a
two-byte character in UTF-8 gets converted to two one-byte characters in
ANSI. I tried to find out if the Workbooks.OpenText method has a parameter
which forces Excel to open the text file as UTF-8 rather than defaulting to
ANSI but couldn't find it. How can we force Excel to open a text file as a
UTF-8 text file when opening text files as workbooks using Workbooks.OpenText?

Thank you very much in advance,
Mete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top