![](/img/trans.png)
[英]System.Runtime.InteropServices.COMException (0x80080005)
[英]System.Runtime.InteropServices.COMException (0x80010108) when creating an instance of Excel in vb.net 3.5
因此,我有一个启动Excel实例的程序。 它既可以在我的机器上运行,也可以在其他两台机器上运行,但是当我的项目负责人尝试使用它时,会出现以下错误:
System.Runtime.InteropServices.COMException (0x80010108): Creating an instance of the COM component with CLSID {00024500-0000-0000-C000-000000000046} from the IClassFactory failed due to the following error: 80010108.
下面的代码是我创建excel实例并启动它的地方。
Dim xlsApp As New Excel.Application
Dim xlsWB As Excel.Workbook
Dim xlsWS As Excel.Worksheet
Try
If ugLoadDeviationsDetails.DataSource IsNot Nothing Then
'Creates a temporary excel file with data located in the grid
UltraGridExcelExporter1.Export(ugLoadDeviationsDetails, "C:\ProgramData\Data-Tronics\ShellFiles\LoadDeviations\tempExcel")
xlsWB = xlsApp.Workbooks.Open("C:\ProgramData\Data-Tronics\ShellFiles\LoadDeviations\tempExcel")
xlsWS = DirectCast(xlsWB.Sheets("Sheet1"), Excel.Worksheet)
DirectCast(xlsWS.Cells.EntireRow, Excel.Range).ClearFormats()
DirectCast(DirectCast(xlsWS.Cells("1", "A"), Excel.Range).EntireRow().Cells, Excel.Range).Interior.Color = Color.LightGray.ToArgb
DirectCast(xlsWS, Excel.Worksheet).Copy()
xlsWB.Close(False)
xlsApp.Visible = True
xlsApp.UserControl = True
Else
RaiseEvent ShowError("Cannot write file when grid is empty.")
End If
Catch ex As Exception
For Each wb As Excel.Workbook In xlsApp.Workbooks
wb.Close(False)
Next
xlsApp.Quit()
Finally
xlsApp = Nothing
xlsWB = Nothing
xlsWS = Nothing
End Try
根据堆栈跟踪,它在以下行中断:
Dim xlsApp As New Excel.Application
项目负责人使用的Excel版本与我使用的版本完全相同(2010),是否有人可以想到任何可能的原因以及如何解决?
尝试这个
xlsApp = CreateObject("Excel.Application")
xlsBook = xlsApp.Workbooks.Add
xlsSheet = xlsBook.Worksheets.Add
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.