Guillaume666
Guillaume666

Reputation: 63

Import UTF-8 file in VBA

I'd like to import a pipe delimited file in a table but this file is in UTF-8 with dynamic structure.

I had tried with TranfertText and FSO but only ADODB.Stream seems to deal well with such an encoding however it only read the full text...

How can I read such a file line per line to add rows in an existing table ?

Thanks in advance.

Upvotes: 2

Views: 597

Answers (1)

HansUp
HansUp

Reputation: 97101

You can read a line from an ADO Stream with its ReadText method.

strLine = objStream.ReadText -2 ' adReadLine

You may need to set your stream's LineSeparator property first.

After you read the line, you can split on the pipe character.

Split(strLine, "|")

Upvotes: 3

Related Questions