title: How to open Excel file written with incorrect character encoding in VBA
body: <p>I read an Excel 2003 file with a text editor to see some markup language.
  When I open the file in Excel it displays incorrect characters. On inspection of the file I see that the encoding is Windows 1252 or some such. If I manually replace this with UTF-8, my file opens fine. Ok, so far so good, I can correct the thing manually.</p>
  
  <p>Now the trick is that this file is generated automatically, that I need to process it automatically (no human interaction) with limited tools on my desktop (no perl or other scripting language).</p>
  
  <p>Is there any simple way to open this XL file in VBA with the correct encoding (and ignore the encoding specified in the file)?</p>
  
  <p>Note, Workbook.ReloadAs does not function for me, it bails out on error (and requires manual action as the file is already open).</p>
  
  <p>Or is the only way to correct the file to go through some hoops? Either: text in, check line for encoding string, replace if required, write each line to new file...; or export to csv, then import from csv again with specific encoding, save as xls?</p>
  
  <p>Any hints appreciated.</p>
  
  <p>EDIT:</p>
  
  <p>ADODB did not work for me (XL says user defined type, not defined).</p>
  
  <p>I solved my problem with a workaround:</p>
  
  <pre><code>name2 = Replace(name, ".xls", ".txt")
  Set wb = Workbooks.Open(name, True, True) ' open read-only
  Set ws = wb.Worksheets(1)
  ws.SaveAs FileName:=name2, FileFormat:=xlCSV
  wb.Close False                    ' close workbook without saving changes
  Set wb = Nothing                  ' free memory
  Workbooks.OpenText FileName:=name2, _
                     Origin:=65001, _
                     DataType:=xlDelimited, _
                     Comma:=True
  </code></pre>