Open an Excel xp application from VB.NET

Z

zargaran

Dear Sir/Madam

I want to open and manipulate an Excel(Office XP) application programaticaly
from VB.NET (VS 2002 with XP OS) but I have a problem.
When I run my application an error appears:

"An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in WindowsApplication1.exe

Additional information: Old format or invalid type library."


Note that I have installed "Office XP PIAs" properly.(This error also appeared before PIAs installation)
I have added "Microsoft Excel 10.0 Object Library" and my code is:

Dim ex As New Microsoft.Office.Interop.Excel.Application()
ex.Visible = True
Dim wb As Microsoft.Office.Interop.Excel.Workbook
wb = ex.Workbooks.Add

The last line "wb = ex.Workbooks.Add" is the error reason.
when I do this job with VB6 and then convert it to VB.NET the error is the same.
Would you please help me? I am really confused!

The following script is error detail.

Best Regards
M.Zargaran






See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80028018): Old format or invalid type library.
at Microsoft.Office.Interop.Excel.Workbooks.Add(Object Template)
at WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\BSS\My Documents\Visual Studio Projects\WindowsApplication1\WindowsApplication1\Form1.vb:line 50
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase: file:///c:/windows/microsoft.net/framework/v1.0.3705/mscorlib.dll
----------------------------------------
WindowsApplication1
Assembly Version: 1.0.1468.28401
Win32 Version: 1.0.1468.28401
CodeBase: file:///C:/Documents%20and%20Settings/BSS/My%20Documents/Visual%20Studio%20Projects/WindowsApplication1/WindowsApplication1/bin/WindowsApplication1.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.3300.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase: file:///c:/windows/assembly/gac/system/1.0.3300.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.3300.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase: file:///c:/windows/assembly/gac/system.xml/1.0.3300.0__b77a5c561934e089/system.xml.dll
----------------------------------------
Microsoft.Office.Interop.Excel
Assembly Version: 10.0.4504.0
Win32 Version: 10.0.4504
CodeBase: file:///c:/windows/assembly/gac/microsoft.office.interop.excel/10.0.4504.0__31bf3856ad364e35/microsoft.office.interop.excel.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration><system.windows.forms jitDebugging="true" /></configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
 
A

Art Leonard [MSFT]

zargaran said:
Dear Sir/Madam

I want to open and manipulate an Excel(Office XP) application programaticaly
from VB.NET (VS 2002 with XP OS) but I have a problem.
When I run my application an error appears:

"An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in
WindowsApplication1.exe
Additional information: Old format or invalid type library."


Note that I have installed "Office XP PIAs" properly.(This error also
appeared before PIAs installation)
I have added "Microsoft Excel 10.0 Object Library" and my code is:

Dim ex As New Microsoft.Office.Interop.Excel.Application()
ex.Visible = True
Dim wb As Microsoft.Office.Interop.Excel.Workbook
wb = ex.Workbooks.Add

The last line "wb = ex.Workbooks.Add" is the error reason.
when I do this job with VB6 and then convert it to VB.NET the error is the same.
Would you please help me? I am really confused!

The following script is error detail.

Best Regards
M.Zargaran
<repost messasge truncated>

M. Zargargan:

This is an issue in Excel when dealing with system locales other than
English typically when running an English Excel SKU. There is documentation
accompanying workarounds available from MSDN:
http://support.microsoft.com/?kbid=320369

I hope this helps you.

- Art
 

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