How to read UTF-8 chars using VBA

M

MSK

Hi,

I am currently developing some Word templates (office 2003) + VBA


I have a UTF-8 encoded text file...I wanted to read and show the
values into a list box...


The charactors are getting changed while reading and filling the
control...(but in the text file they are perfect)


I tried FSO and Open statement with Line input.. I dont know how to
Convert into normal chars..


How to resovle.. ?


Its bit urgent...give me some useful links


Many thanks.
MSK.
 
T

Tony Jollans

There are other ways I'm sure, but try this to get you going:

Dim File ' As ADODB.Stream
Set File = CreateObject("ADODB.Stream")
File.Open
File.Type = 2 ' adTypeText
File.Charset = "UTF-8"
File.LoadFromFile "C:\path\file.etc"
myString = File.ReadText

File.Close

It should work as is with late binding or you can early bind with a
reference to Microsoft ActiveX Data Objects 2.5 or later, and use the
commented bits.
 

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