View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Carol Xie[_2_] Carol Xie[_2_] is offline
external usenet poster
 
Posts: 1
Default OfficeXP PIA compatibility

Mr. Wei-Dong,
I am running VB.Net on XP and try to program with
Office 2003 (Excel 2003).
The following is my first test program.
I installed the PIA through the Office 2003 upgrade by
checking the ".Net Programability Support". I Added
the "Microsoft Excel 11.0 Object Library" to the VB
project as Reference. I could see the Object in the
design view object dropdown box except the Excel.Range
(don't know why??). When I debug the code step by step,
it passed the first three object binding. But I got run
time error at the line

Dim objWB As New Microsoft.Office.Interop.Excel.Workbook

Here is the Error Msg
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 re-
install the Office Upgrade. The same error is encountered
at the same line of code.
Could you give me any clue for what is wrong and how
to solve this.
Thank you very much



------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:
A Primer to the Office XP Primary Interop Assemblies
http://msdn.microsoft.com/library/en-

us/dnofftalk/html/office10032002.asp?frame=true

Primary Interop Assemblies (PIAs)
http://msdn.microsoft.com/library/en-

us/dndotnet/html/whypriinterop.asp?frame=true

Please feel free to let me know if you have any further

questions.

Does this answer your question? Thank you for using

Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and

confers no rights.


.