none
cant create an instance of excel.application RRS feed

  • Question

  • hallo, everyone,

    we have a Desktop-App (vb.net), and need open Excel from program, and we just used 

    xlsWorkbook = CType(System.Runtime.InteropServices.Marshal.BindToMoniker(filePath), Excel.Workbook)

    xlsApp = CType(xlsWorkbook.Parent, Excel.Application)

    and it works fine except by one user,

    and we tried 

    xlsApp = New Excel.Application     or 

    xlsApp = CType(CreateObject("Excel.Application"), Excel.Application) 

    and it cant work with his computer, by other users are ok.

    i think its nothing to do with our code, just one com-component in his computer is missing, such like interop.excel.dll or sth else.

    anyone know this? can anyone help?

    thanks a lot!

    Wednesday, August 10, 2016 1:49 PM

Answers

  • Hi,

    all this interop is quie likely to fail. You have to check multiple things:

    a) Which version of Office (Excel) is installed? Does this version work correctly with the COM component you linked the software to?

    b) x86 or x64? Office is available in 32 and 64 bit. Your application can run in 32 and 64 bit. That simply has to match.

    There are the main points that you should check.

    But you should also check what you want to get. If you just want to write data to an excel file, then it might be easier to use the OleDb Data Provider. Hast te big advantage that the Access (that includes Excel) part is free. And AFAIK you can install the 32 and 64 bit together on one system. But of course: Complex stuff is not possible that way.

    With kind regards,

    Konrad

    • Marked as answer by Patrick9527 Friday, August 12, 2016 8:40 AM
    Wednesday, August 10, 2016 2:43 PM
  • Btw, just some correction to (b). Since Office Interops are Out-Of-Proc COM component, as long as you're using the corresponding version of PIA assembly, it's not subject to the limitation of requiring the same "bit-ness" to work.

    And btw again, these PIA only works on .NET v2.x runtime, so you're advised to also install .NET v3.5SP1 on those machines even if you're target .NET v4.X.


    Thursday, August 11, 2016 1:49 AM
    Answerer

All replies

  • Hi,

    all this interop is quie likely to fail. You have to check multiple things:

    a) Which version of Office (Excel) is installed? Does this version work correctly with the COM component you linked the software to?

    b) x86 or x64? Office is available in 32 and 64 bit. Your application can run in 32 and 64 bit. That simply has to match.

    There are the main points that you should check.

    But you should also check what you want to get. If you just want to write data to an excel file, then it might be easier to use the OleDb Data Provider. Hast te big advantage that the Access (that includes Excel) part is free. And AFAIK you can install the 32 and 64 bit together on one system. But of course: Complex stuff is not possible that way.

    With kind regards,

    Konrad

    • Marked as answer by Patrick9527 Friday, August 12, 2016 8:40 AM
    Wednesday, August 10, 2016 2:43 PM
  • Btw, just some correction to (b). Since Office Interops are Out-Of-Proc COM component, as long as you're using the corresponding version of PIA assembly, it's not subject to the limitation of requiring the same "bit-ness" to work.

    And btw again, these PIA only works on .NET v2.x runtime, so you're advised to also install .NET v3.5SP1 on those machines even if you're target .NET v4.X.


    Thursday, August 11, 2016 1:49 AM
    Answerer
  • ty, i will check it.
    Friday, August 12, 2016 8:39 AM