I have a UTF-8 CSV file stored on a web server. When I download the file put it on my hard drive and I then import it into an Excel sheet with this macro (from the macro recorde
IMO, there seems to be a bug/conflict in Excel when opening UTF-8/UTF-8-BOM files using the recorded macro code, specifically when the Origin
parameter is set to 65001
which is supposed be UTF-8.
I have found two workarounds to this issue:
Remove the Origin
parameter from the function call and see if the file loads properly Workbooks.OpenText Filename:="C:\file.csv"
.
MSDN says:
If this argument is omitted, the method uses the current setting of the File Origin option in the Text Import Wizard.
I would think that as soon as you link the file with Excel, it should try to read the header of the file and select the correct Country Code automatically (well, assuming the header is not missing).
I have tried different Country Codes and found that in my specific scenario setting Origin:=1252
(1252 - windows-1252 - ANSI Latin 1; Western European (Windows)
) loads the file in Excel just fine.