TheSwamp
Code Red => .NET => Topic started by: Ricky_76 on June 07, 2007, 11:15:34 AM
-
Hi,
I have some problem with my last application.
I work with vb.net 2005 and I have used the PIA to connect my application with excel file.
All the staff works very well, but I need to let it work in a computer with Office 2000 and the PIA works only for Office XP, 2003 or 2007.
I have modified the application using alternative methods:
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
xlApp = CreateObject("Excel.Application")
...
but during the execution the program stop with the following error:
"Unable to cast COM object of type 'System.__ComObject' to interface type 'Excel.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: Libreria non registrata. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))."
"Libreria non registrata"
means
"Library not registered"
HOW TO solve the problem??
I have uninstalled office 2003 from my computer, and then I have installed the 2000 version. It works, but in some other computers doesn't.
tnx a lot
/r
ps
I can't install office xp or greater in the computer where the application have to run! :(
-
Here is the function from one of my prog's
I think that it may helps
~'J'~
Friend Function ReadExcel(ByVal Path As String) As String(,)
Dim app As Excel.ApplicationClass = New Excel.ApplicationClass
Dim workBook As Excel.Workbook = app.Workbooks.Open(Path, 0, True, 5, "", "", True, Excel.XlPlatform.xlWindows, "" & Microsoft.VisualBasic.Chr(9) & "", False, False, 0, True, 1, 0)
Dim workSheet As Excel.Worksheet = CType(workBook.Worksheets(1), Excel.Worksheet)
Dim SheetRange As Excel.Range = CType(workSheet.UsedRange, Excel.Range)
Dim rowIndex As Long = SheetRange.Rows.Count
Dim colIndex As Long = SheetRange.Columns.Count
Dim valArray(0 To rowIndex - 1, 0 To colIndex - 1) As String
Dim itm As String
Try
For i As Long = 1 To rowIndex
For j As Long = 1 To colIndex
Dim val As String = CType(SheetRange.Cells(i, j), Excel.Range).Value.ToString
If Not val Is Nothing Then
itm = val
Else
itm = "Empty"
End If
valArray(i - 1, j - 1) = itm
Next
Next
Catch ex As Autodesk.AutoCAD.Runtime.Exception
app.Quit()
End Try
Return valArray
End Function
-
Tnx,
I'll try it!
/r