Link to home
Start Free TrialLog in
Avatar of clylv
clylv

asked on

VB.NET >> EXCEL 2000

Hello,

Have a strange problem when I try to create a Workbook in excel from VB.Net(it works in VB6). the error message i get when executing the line: oWorkbook = oExcel.Workbooks.Add("C:\Temp\Template.xls") is: "Old Format or invalid Type library. (32792)"
I have faild trying to find out what that means, since I am using COM in both VB6 and .NET it should not precent a problem but never the less it does.
Anyone have any ideas?

(Here is the test code I use):

Dim oExcel As Excel.Application
Dim oWorkbook As Excel.Workbook
Dim sTemplate As String
oExcel = New Excel.Application()
On Error GoTo ConvertToXL_Error
oWorkbook = oExcel.Workbooks.Add()
Exit Sub
ConvertToXL_Error:    
MsgBox("Error when converting to Excel." & vbCrLf & "(" & Err.Description & " (" & Err.Number & ") )")



/Claes
Avatar of GoodJun
GoodJun

Make sure the Excel you referenced in the project is the same version with the Excel file you want to ADD("C:\Temp\Template.xls"). You may reference a higher version of Excel in project but the template.xls is an older version.
I tested your code, it works. I referenced Excel 10.0 objcet library.
Avatar of clylv

ASKER

I have solved the problem my self, the thing was that the language in my operation system was Swedish and I had an English version of Excel... go figure..

Regards
Claes
ASKER CERTIFIED SOLUTION
Avatar of GoodJun
GoodJun

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of clylv

ASKER

GoodJun,
I am not sure that you realy deserve the points since the problem was not in Excel or Excel versions but in the language-pack of the operating system, but never the less you took time to write me a hint and try my code so I think you should have the credits. in short agreed.