Excel 2002 problem

When trying to export to excel I've got a problem in the ExportTasks method

The exception says:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in TaskVision.exe

Additional information: Old format or invalid type library.

I do have Office XP with SP2 installed, no problem running or compiling the program. Everything seems ok, except the above mentioned problem


Answer this question

Excel 2002 problem

  • Greg Darmo

    Josh, that's a really question!

    As far as best practices, I think it's fair to say that COM interop is preferrable when the dependency files are being distributed with the application (or every client has the same library installed). In this case, the MS Office files could not be distributed and late binding would have probably been a better solution.

    The reason why COM interop was chosen for this - was more for display, to demonstrate the feature (since late binding is nothing new).

  • Steve Fu

    This does bring up a good question. Typical uses of Office in the past for me were done in Visual Basic.  With VB you can simply do late binding of everything, so basically after I had written early binding code and got it working the way I wanted to I would remove the reference and convert everything to objects.

    I know you can still do this in VB.NET, not sure about C# (I would believe not, as "Option Strict Off" doesn't exist ;)), so what is the "best practices" method for this   Having to recompile with the new reference seems silly for cases like this.

  • Nightw0lf

    I'm afraid it didn't help me.
    Same exception raised.
    it happens in line 28 of exporttasks where the code says:
    workBook = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet)

    any suggestions

  • MaungMaung

    Problem solved
    There is a bug in excel, described in KB320369, it regards using an english version of excel but working with another locale.

    problem solved using the following code before executing the line with an error
    System.Threading.Thread.CurrentThread.CurrentCulture =
        System.Globalization.CultureInfo.CreateSpecificCulture("en-US")

    Thanks for all replies

  • Adria Grau

    Sorry about that - Try this: In the references of the client project remove the MS Office, Excel, and VBIDE references; and then add them again. You should only need to add one reference, under the COM tab, the MS Excel 10.0 Type Library (this will add the other dependency files). Now try to rebuid.
  • Excel 2002 problem