title: OLEDB Connection String Fails - Except When Excel Is Open...?
body: <p>I'm trying to programatically read the contents of an Excel spreadsheet (.xlsm format) using the Microsoft.Jet.OLEDB.4.0** in C#.</p>
  
  <p>My connection string is:</p>
  
  <blockquote>
    <p><strong>Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties="Excel 8.0;HDR=YES;IMEX=1;"";Data Source="C:\Test.xlsm"</strong></p>
  </blockquote>
  
  <p>When I execute my code, it fails with an exception stating:</p>
  
  <blockquote>
    <p><strong>OldDbException was unhandled by user code</strong></p>
    
    <p>External table is not in the expected format.</p>
  </blockquote>
  
  <p>However - if I open the Test.xlsm file in Excel and re-run my code, it works with no exception and performs as intended.  No problems, works great.</p>
  
  <ul>
  <li>Why/How does having a particular file open in Excel change how my code is accessing it?</li>
  <li>What is the correct way to open a .xlsm file with the Microsoft Jet OLEDB provider?</li>
  </ul>
  
  <p>Additional Information:
  Running Windows 7 x64 / Excel 2010</p>