Interop troubles with excel

I asked this in the VB forum, but think it is more suited here. My application (VS2005) uses the interop assembly 11.0 to communicate with excel.

11.0 is the version for excel 2003. When I put the application on a client machine, it's fine provided the user has excel 2003 and either the PIAs are installed, or I distribute the dlls with my application.

However, I've just tried this on a machine with O2007 and it's not working. I have installed the O2007PIAs on the client machine.

Any ideas I assumed the O2007PIAs would be compatable with O2003...



Answer this question

Interop troubles with excel

  • jayaseelan

    The answer is to replace range with cells, ie

    objsheet.cells(row,column).value


  • ernisj

    Just one more thought...

    I also read in data from excel using the PIA, can I still do this with Late Binding


  • EltonSky

    Paul P Clement IV wrote:


    No, the PIAs are version specific.

    If you are supporting multiple versions of Excel then you should be using late binding.

    How To Use Visual Basic .NET for Binding for Office Automation Servers

    Thanks - that looks simple enough to change to. I did actually get O2007 to work - not sure how though! From what I can see about late bindings it should get rid of all the version specific problems.

    Are there disadvantages to using late binding I'm assuming that as they went to the trouble of creating PIAs, there must be a reason


  • satya999


    Early binding is typically preferable since there is type checking at compile time when references are resolved. With late binding the references are resolved at runtime. You also lose the intellisense feature during development.

    There is also a slight performance advantage when using early binding but may not be noticeable under most circumstances.



  • Leonard Lee


    No, the PIAs are version specific.

    If you are supporting multiple versions of Excel then you should be using late binding.

    How To Use Visual Basic .NET for Binding for Office Automation Servers



  • GregWilliams

    It is quite possible it will not be compatible, since I would expect that library was changed significantly. Why do you need to use Interop Can you just access it using Jet OLEDB provider or some other component that does not require Interop and Excel installed on clients PC

  • Dennis van.der Stelt


    Yes. You can use late binding with just about any COM object. No PIA or COM reference is required. In this instance a default generic interop assembly is created on the fly.

  • Yafarmo


    I wouldn't think it would matter which Cell reference you use. Are you having a problem using the row-column method under late binding

  • Rykie

    Conversion to late binding is going well, however I have one issue..

    Referencing an excel cell via the PIAs was done numerically in the format (row, column), so row 12 column 2 was (12, 2)

    However late binding uses the format ("B12") to reference the same cell.

    I have a few for/next loops where the column is incremented.

    Is there any simple way to convert numbers to alphabetical eg 3 to c or do I need to write my own routine

    Thanks


  • Elie Rodrigue

    Yes, these work:

    objSheet.Range("b18")

    objSheet.Range("a" & row).value

    But this throws a COMException error:

    objSheet.Range(row, column).value


  • Interop troubles with excel