Hi,
I am using VB.NET 2003 and try to program using Excel
2003 (Office 2003 Upgrade) on XP. I installed the PIA
through the Office 2003 by checing the ".Net
Programability Support". In the VB project , I added
the "Microsoft Excel 11.0 Object Library".
The following is my first test code. I have two
problems.
1. In the design view, I could see the
Excel.Application,Excel.Workbook,Excel.WorkSheet etc. But
I could not see the Excel.Range object in the dropdown
box.
2. When I debug the code step by step, it passed the
first three object declaration lines. But, I got run time
error at the line
Dim objWB As New Microsoft.Office.Interop.Excel.Workbook
The error messag 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 with this
CLSID is there. I even re-installed the Office 2003 and
PIA several time. I still get the same error at the same
place.
Here is the PIA info I got from GAC (gacutil /l ...)
Microsoft (R) .NET Global Assembly Cache Utility.
Version 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights
reserved.
The Global Assembly Cache contains the following
assemblies:
Microsoft.office.Interop.Excel, Version=11.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c,
Custom=null
The cache of ngen files contains the following entries:
Number of items = 1
Do you have have any clue to solve this??
Thank you for your help!
Carol
---------------VB 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
''Dim objRange As New
Microsoft.Office.Interop.Excel.
objWB = objApp.Workbooks.Open
("C:\VBCode\TestData\WRDS_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
-----Original Message-----
Hi vincent,
PIA means Primary Interop Assembly which is used to help
the solution developer to leverage all the new
capabilities of the Microsoft .NET Framework
and to access Microsoft Office in a reliable and
consistent way. The office object model from PIA is
compatible within 10 and 11.
From my experience on this issue, please remember to
deploy the app-related PIA version to the users' boxes.
Therefore, if you develop one solution
with the office xp PIA, your application will call the
office xp PIA assembly from GAC. The version of Office XP
PIA is 10.0.4504.0. During runtime, the
application will try to find this version of PIA
assembly from GAC and then load it. If it is not able to
find it, it will report the FileNotFoundException
exception. Also then, if you develop the app with office
11, your application will need the 11 version of PIA to
run. When you deploy the application
to users, you should firstly check the PIA version in
the GAC so that you can deploy the app-related PIA to the
destination. This is because CLR will
check the version of referenced assembly.
In another way, if you develop the solution with office
XP, you can recompile it in the office 11 located box and
will only need to change the PIA
reference to a newer version. In this way, your
application can run with office 11 PIA without modifying
the codes.
For more information on this Office XP PIA issue, I'd
suggest two msdn articles that may help. Please go to: