title: Export SQL Server table to Microsoft Excel xlsx file
body: <p>I have to replace a VB6 function that allows to export a SQL Server table in a xls file using DAO.</p>
  
  <p>In order to use Excel 2007-2010... files (xlsx), I tried to use this function to do that but it doesn't work.</p>
  
  <p>Here is the DAO functionnality :</p>
  
  <pre><code>//Opening the SQLServer database with DAO
  Set oBase= DBEngine.OpenDatabase(DSNName, dbDriverNoPrompt, False, "ODBC,PROVIDER=Microsoft.JET.OLEDB.3.51;DSN=DSNName;UID=user;PWD=pwd;DATABASE=SQLServerBDDName;Server=SQLServerName;")
  
  //Query to export data
  oBase.Execute("SELECT * INTO [SheetName] IN 'xlsFileName' 'Microsoft Excel 8.0;' FROM [SQLServerTableName]")
  </code></pre>
  
  <p>This function works perfectly with 97-2003 Excel files in xls but not with xlsx files.</p>
  
  <p>Is there a possibility to make the same thing with ADO but without OPENROWSET statements or stored procedures ?</p>
  
  <p>Thanks for your help </p>