1

I wrote a VB .NET program that opens an Excel Workbook to put some values. Here is the code that open the file:

OpenFileDialog1.FileName = ""
OpenFileDialog1.Filter = "Excel files (*.xls)|*.xls"
OpenFileDialog1.ShowDialog()
filePath = OpenFileDialog1.FileName
If System.IO.File.Exists(filePath) Then
  oExcel = CreateObject("Excel.Application")
  oExcel.Visible = True
  oBook = oExcel.Workbooks.Open(filePath)
End If

This worked well until I had to run it on an old computer wich didn't have .NET Framework 4.5 nor 4.0

I then change the Framework target to 3.5 and it gave me this error when running:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualBasic.dll

Additional information: Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))

I guess the way to open an Excel file is not the same for 3.5 or 4.5 so I don't know how I should do.

1
  • Are you also targeting x86 or x64 in the compile? Depending on your version of Office, it may require x86. Commented Mar 26, 2014 at 15:49

1 Answer 1

1

Maybe you could find some earlier Interop Libs that used .Net 3.5 ?

When I was targeting Office 2010 and 2007, I found if I used the 2010 Interop DLLs I could use them to talk to 2007 and 2003 Office as well. I could not use any functionality that was only present in the later versions.

This was from different versions of .NET up to 3.5, I didn't try higher. Not sure if your using the same method as myself and I was using C#, but not sure that matters. If your using 32bit Office make sure you build x86 .net apps.

Sign up to request clarification or add additional context in comments.

3 Comments

I am not at all familiar with all this DLL stuff.. Where could I find earlier DLLs and how could I install them?
They come with each version of Visual Studio... so VS 2012 are @ C:\Program Files (x86)\Microsoft Visual Studio 11.0\Visual Studio Tools for Office\PIA\Office14
Your best bet would be to develop with VSTO - Visual Studio Tools (for) Office. Check it out on MSDN.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.