VB.NET and Excel2003 COM Object and PIA

C

Carol Xie

I am using VB.Net 2003 and try to program with Office
2003 Excel. I upgraded from Office 2002 to 2003.
I installed the Office Primary Interop Assemlies
through the Office 2003 (By checking .Net Programmability
Support).In the VB.Net program, I added reference
to "Microsft Excel 11.0 Object Library". The first test
program just tries to create
Excel.Application,Excel.WorkBook,etc. (see below). It
passed the Build except the Range object. But I got run
time error at the line
Dim objWB As New Microsoft.Office.Interop.Excel.Workbook

The error mesasge is

A first chance exception of
type 'System.Runtime.InteropServices.COMException'
occurred in TestExcel.exe

Additional information: COM object with CLSID {00020819-
0000-0000-C000-000000000046} is either not valid or not
registered.

I checked the Registry, the COM object is there. I
even tried to delete the Registry Key and re-install the
Office 2003. I still got the same error at the same line.

Another problem with this Excel COM and PIA is , I
could not see the Range object in the Design view Object
dropdown box when I type
Dim objRange As New Microsoft.Office.Interop.Excel.

Is there any bug in the Excel2003 or the PIA with it??

Thank you for your input.


Carol Xie



------VB.Net Test Code.
Module TestExcel
Sub main()

Dim objWkSheet As New
Microsoft.Office.Interop.Excel.Worksheet
Dim objRolCol As New
Microsoft.Office.Interop.Excel.XlRowCol
Dim objApp As New
Microsoft.Office.Interop.Excel.Application
Dim objWB As New
Microsoft.Office.Interop.Excel.Workbook
''m objRange As New
Microsoft.Office.Interop.Excel.Range

objWB = objApp.Workbooks.Open
("C:\VBCode\TestData\Excel_Test\Test Data 1.xls")
objWkSheet = objWB.Worksheets.Item(0)
objRolCol = objWkSheet.Cells(1, 1)
MsgBox("Cell1_1:" + objRolCol.ToString())

objWB.Close()
objApp.Quit()
objRolCol = Nothing
objWkSheet = Nothing
objWB = Nothing
objApp = Nothing


End Sub



End Module
 

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