title: VBA importing UTF-8 CSV file from a web server
body: <p>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 recorder) :</p>
  
  <pre><code>Sub Macro2()
  Workbooks.OpenText Filename:= _
      "C:/myFile.csv", Origin _
      :=65001, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
      xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False _
      , Comma:=True, Space:=False, Other:=False
  End Sub
  </code></pre>
  
  <p>All of the characters (vietnamese characters) are displayed correctly.</p>
  
  <p>When I try the same macro but instead of giving the local address of the file ("C:/myFile.csv") I pass the URL of the file ("<a href="http://myserver.com/myFile.csv">http://myserver.com/myFile.csv</a>") the CSV is correctly imported into my Excel sheet but the vietnamese characters are not displayed correctly anymore.</p>
  
  <p>I have also tried using the Data tab but the encoding seems be ignored by Excel:</p>
  
  <pre><code>With ActiveSheet.QueryTables.Add(Connection:= _
                  "TEXT;C:/myFile.csv" _
                  , Destination:=Range("$A$1"))
                  .Name = "myFile.csv"
                  .FieldNames = True
                  .RowNumbers = False
                  .FillAdjacentFormulas = False
                  .PreserveFormatting = True
                  .RefreshOnFileOpen = False
                  .RefreshStyle = xlInsertDeleteCells
                  .SavePassword = False
                  .SaveData = True
                  .AdjustColumnWidth = True
                  .RefreshPeriod = 0
                  .TextFilePromptOnRefresh = False
                  .TextFilePlatform = 65001
                  .TextFileStartRow = 1
                  .TextFileParseType = xlDelimited
                  .TextFileTextQualifier = xlTextQualifierDoubleQuote
                  .TextFileConsecutiveDelimiter = False
                  .TextFileTabDelimiter = True
                  .TextFileSemicolonDelimiter = False
                  .TextFileCommaDelimiter = False
                  .TextFileSpaceDelimiter = False
                  .TextFileOtherDelimiter = "~"
                  .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
                  .TextFileTrailingMinusNumbers = True
                  .Refresh BackgroundQuery:=False
         End With
  </code></pre>
  
  <p>Sample data: <code>Â„; Â; Â˜; Â1/4; Â‰; Â™,Â™</code></p>
  
  <p>which Excel reads wrongly as: <code>Ã‚â€ž; Ã‚; Ã‚Ëœ; Ã‚1/4; Ã‚â€°; Ã‚â„¢,Ã‚â„¢;</code></p>