Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel Automation Workbooks.Open fails: "Unable to get the Open Property ..."

Tags:

asp.net

excel

I'm working with a web application that performs some Excel automation (I know - not a preferred solution).

I am using Excel 2007 as my development platform but the target server uses Excel 2003. After experiencing a lot of headaches with the Excel 12 interop trying to be loaded on the target server even though I expressly selected Excel 11 during development, I have resorted to using late binding rather than early binding.

This has allowed me to get as far so as to instantiate Excel (and I can see the Excel process start in task manager on the target server).

However I am unable to invoke the Open method of the late-bound Workbooks object. It throws this error at me:

"Unable to get the Open property of the Workbooks class"

I have been experimenting with a few different things and have tried the following:

  • Try the same Workbooks.Open call using late-binding VBScript (e.g. a vbs file).
  • Try the same Workbooks.Open call using late-binding VBA code (e.g. in Excel).
  • Try the same Workbooks.Open call using late-binding .NET code in a Windows Forms application.
  • In all three cases, the Excel automation succeeds. It's only when I deploy the ASP.NET application that this error crops up. In a very simplified form, the code resembles:

    Dim xlApp As Object 'Excel.Application
    Dim xlBook As Object ' Excel.Workbook
    xlApp = CreateObject("Excel.Application") 'New Excel.Application
    xlBook = xlApp.Workbooks.Open("somefile.xls", , True, , , , , , , , , , , , False)
    

    Does anyone have any ideas as to what might be happening? I checked the user that the Excel process starts as, and it is the same user that I successfully ran the Windows Forms .NET application as successfully. I had already opened Excel as this user to clear all the initial setup stuff.

    like image 464
    acee Avatar asked Aug 02 '11 15:08

    acee


    1 Answers

    I'm getting this same problem and I found some sites saying the following: Try going to file - options - add-ins - select diabled add-ins in the manage dropdown - click go - and enable anything in there.

    It didn't work for me but it might for you.

    like image 181
    zw87 Avatar answered Nov 09 '22 12:11

    zw87