Error: old format or invalid type library

J

Jac Tremblay

Hi,

I have created a WinApp project that automates Word. I have followed the
code examples in the MSDN documentation
(http://msdn2.microsoft.com/en-us/library/78whx7s6(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://msdn2.microsoft.com/en-us/library/syyd7czh(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.
 
N

neilspink

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()
 
E

esub.patan

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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top