Hi All,
When I open an Excel file, I got the following runtime error:
---------------------
System.Runtime.InteropServices.COMException was unhandled ErrorCode=-2147221164
Message="Retrieving the COM class factory for component with CLSID {00020819-0000-0000-C000-000000000046} failed due to the following error: 80040154."
---------------------
My code is listed below (the error comes from the highlighted statement, please tell me the reason):
<===========================
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
Public fname As String
Public inApp As Excel.Application
Public inBook As Excel.Workbook
Private Sub btnReadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReadFile.Click
inApp = New Excel.Application
inBook = New inApp.Workbook
fname = txtInFile.Text + ".xls"
inBook.Open(Filename:=fname)
End Sub
Private Sub btnCloseFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCloseFile.Click
inBook.Close()
inBook = Nothing
inApp.Quit()
inApp = Nothing
End Sub
End Class
============================>
I use Office 2003, so, I've added an Excel 11.0 object library and Office 11.0 object library.
Mike
When I open an Excel file, I got the following runtime error:
---------------------
System.Runtime.InteropServices.COMException was unhandled ErrorCode=-2147221164
Message="Retrieving the COM class factory for component with CLSID {00020819-0000-0000-C000-000000000046} failed due to the following error: 80040154."
---------------------
My code is listed below (the error comes from the highlighted statement, please tell me the reason):
<===========================
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
Public fname As String
Public inApp As Excel.Application
Public inBook As Excel.Workbook
Private Sub btnReadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReadFile.Click
inApp = New Excel.Application
inBook = New inApp.Workbook
fname = txtInFile.Text + ".xls"
inBook.Open(Filename:=fname)
End Sub
Private Sub btnCloseFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCloseFile.Click
inBook.Close()
inBook = Nothing
inApp.Quit()
inApp = Nothing
End Sub
End Class
============================>
I use Office 2003, so, I've added an Excel 11.0 object library and Office 11.0 object library.
Mike