none
ODBC error when opening a XLSM (excel) file RRS feed

  • Question

  • Hi.

    I'm trying to open an Excel *.xlsm file using the following C# code:

    string PathToFile = C:\Documents and Settings\Ricardo\Desktop\Planilhas servidor\RDQ_Papel_OC-2014_Rev05.xlsm
    string strConn = string.Format(@"Driver=Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb);DBQ={0};", PathToFile); objConn objConn = new OdbcConnection(strConn); objConn.Open();

    If the file is already opened, the code above works fine. If don't, the code gives me the following errors:

    ERROR [HY000] [Microsoft][Driver ODBC Excel] External table is not in the expected format.
    ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
    ERROR [HY000] [Microsoft][Driver ODBC Excel] External table is not in the expected format.

    What can I do to solve this problem?


    • Edited by Leonardo.Cruz Wednesday, November 5, 2014 1:19 PM
    • Moved by Amanda Zhu Thursday, November 6, 2014 7:33 AM better forum
    Wednesday, November 5, 2014 1:16 PM

All replies

  • Wednesday, November 5, 2014 1:50 PM
  • I'm using Excel 2007 and tried to remove and add again the odbc entry for 'Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)' but it still didnt working..

    Is it an Office 2007' problem and, bacause of it, I wont be able to read a xlsm file when it is closed?

    Wednesday, November 5, 2014 4:12 PM
  • According to that forum I mentioned it's not possible. Please, could you send me the file to try to reproduce your error?
    Wednesday, November 5, 2014 4:33 PM
  • Please, download the file here: https://www.mediafire.com/?61spopcdz3ud4de


    Wednesday, November 5, 2014 6:26 PM
  • My firewall is blocking that. Could you send me: dericferreira@hotmail.com
    Wednesday, November 5, 2014 6:28 PM
  • I've just sent it to you.

    Thanks!

    Wednesday, November 5, 2014 7:20 PM
  • I have tested it and faced other problems:

    ERROR [42000] [Microsoft][Driver ODBC Excel] Não é possível efetuar a atualização. O banco de dados ou objeto é somente leitura.

    ERROR [IM006] [Microsoft][ODBC Driver Manager] Falha de SQLSetConnectAttr do driver

    ERROR [42000] [Microsoft][Driver ODBC Excel] Não é possível efetuar a atualização. O banco de dados ou objeto é somente leitura.

    Wednesday, November 5, 2014 7:32 PM
  • Hi Leonardo,

    For your issue, ADO.NET Managed Providers forum is a support forum. I moved this thread there. Providers Experts can provide you better support.

    Thanks,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 6, 2014 7:35 AM
  • Can you use ACE OLEDB instead? Not sure about support for .xlsm files via ODBC.

    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsm;Extended Properties="Excel 12.0 Macro;HDR=YES";  


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Monday, November 10, 2014 8:19 PM