我有一个将数据写入excel的应用程序。当我通过双击手动运行.exe时,它运行良好。 现在,我想按计划任务运行,但是在事件查看器中看到一个.net错误:
System.Runtime.InteropServices.COMException 在Microsoft.Office.Interop.Excel.Workbooks.Open(System.String,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System .Object,System.Object,System.Object,System.Object,System.Object,System.Object))
下面是部分代码:
Dim testworkbook As Workbook = Nothing
Dim testworksheet As Worksheet = Nothing
Dim countcell As Integer = 1
Dim failcell As Integer = 3
Dim Machine As String
Dim WMBBdate As String
Dim OSCmachine As String
Dim OSCdate As String
Dim xls As New Microsoft.Office.Interop.Excel.Application
xls.DisplayAlerts = False
xls.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityLow
testworkbook = xls.Workbooks.Open("\\YY088132\Users\310288557\Desktop\Virtual Line auto email\Test3.xlsx")
testworksheet = testworkbook.Worksheets("Sheet1")
testworksheet.UsedRange.Clear()
testworksheet.Cells.Font.Color = ColorTranslator.ToOle(System.Drawing.Color.Black)
我怀疑它停在打开工作簿的行上。
我尝试了在Google上找到的所有可能的解决方案,例如:
syswow64
和system32
上