Error: old format or invalid type library

Error: old format or invalid type library

Post by SmFjIFRyZW » Fri, 08 Feb 2008 09:30:04


Hi,

I have created a WinApp project that automates Word. I have followed the
code examples in the MSDN documentation
( http://www.yqcomputer.com/ (VS.80).aspx) and it works
fine.

Here's some simple code that I use.

Imports Microsoft.Office.Interop.Word

Public Class frmWord02
Dim wdApp As Microsoft.Office.Interop.Word.Application
Dim wdDoc As Microsoft.Office.Interop.Word.Document
Dim wdDoc2 As Document
Private Sub cmdWordApp_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdWordApp.Click
wdApp = New Microsoft.Office.Interop.Word.Application
wdApp.Visible = True
wdDoc = wdApp.Documents.Add
wdDoc2 = wdApp.Documents.Add("Calotte.dotx")
wdDoc2.Activate()

...

I'm am trying now to do the same with Excel
( http://www.yqcomputer.com/ (VS.80).aspx) but it does
not work. The Excel app is created, but no workbook can be created. I get
this message (translated from French): "Error: old format or invalid type
library - HRESULT EXCEPTION: 0X80028018 (TYPE_E_INVDATAREAD)".

What can be the problem?
I checked the references and Imports statement and everything is fine.
Here's (some of) the code for the WinApp Excel application:

Imports Microsoft.Office.Interop.Excel
Public Class frmExcel
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlWbk As Microsoft.Office.Interop.Excel.Workbook
Private Sub cmdAddNewWorkbook_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdAddNewWorkbook.Click
xlApp = New Microsoft.Office.Interop.Excel.Application
xlApp.Visible = True
Try
xlWbk = xlApp.Workbooks.Add() 'Error here...
...
I have Windows XP Pro, VS.NET 2005 Pro and Office 2007 and 2003 (except for
Outlook - I kept 2003 for now).
I would really appreciate some help.
Thanks.
--
Jac Tremblay
 
 
 

Error: old format or invalid type library

Post by neilspin » Sat, 15 Mar 2008 23:27:33


It's a bug. Adding the following code worked for me:

System.Threading.Thread.CurrentThread.CurrentCulture =
System.Globalization.CultureInfo.CreateSpecificCulture("en-US")

xlWbk = xlApp.Workbooks.Add()