I have a script task (excerpt code below) which is supposed to open an Excel Workbook:
If CountOfT > 0 Or RowsUnallocated > 0 Then
Workbook = Workbooks.Open(BrkStTmpFolder + "NewTemplate.xlsx")
'MsgBox("Break Point")
'Workbook.Save()
Else Exit Sub
End If
ExcelApp.visible = False
ExcelApp.DisplayAlerts = False
Workbook.DoNotPromptForConvert = True
'MsgBox("Break Point")
The code basically is supposed to open the Excel Template which then goes on to be populated by other Script Tasks whilst its open from some data in SQL Server.
When I run it in Visual Studio it runs perfectly but when I deploy to SQL Server and try to execute it there it fails at this particular Script Task with some like "Exception has been thrown by the Target of an Invocation"
Insight and help appreciated
Thanks
PS
I also have this code to kill all running Excel processes before opening the Excel Template
Dim pName As String = "EXCEL"
Dim psList() As Process
Try
psList = Process.GetProcesses()
For Each p As Process In psList
If (pName = p.ProcessName) Then
'MsgBox(p.ProcessName) 'TEST LINE
p.Kill()
'MsgBox("Process Found")
End If
Next p
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try