Current Position:Home > Getting error message when i am trying to update the excel file using script task in ssis package

Getting error message when i am trying to update the excel file using script task in ssis package

Update:10-11Source: network consolidation
Advertisement
Hi Guys,
I am getting error message when I am trying to update the excel. Please find the error messages as below
Error at Update File [Update File]: Failed to compiled scripts contained in the package. Open the package in SSIS Designer and resolve the compilation errors.
Error at Update File [Update File]: BC30002 - Type 'Microsoft.Office.Interop.Excel.Application' is not defined., ScriptMain.vb, 32, 32
Error at Update File [Update File]: BC30002 - Type 'Microsoft.Office.Interop.Excel.Workbook' is not defined., ScriptMain.vb, 33, 25
Error at Update File [Update File]: The binary code for the script is not found. Please open the script in the designer by clicking Edit Script button and make sure it builds successfully.
Warning at Update File [Update File]: Found SQL Server Integration Services 2008 Script Task "ST_050fcae972904039b4f0fe59b7528ece" that requires migration!
and the code that   I am using is
Dell - Internal Use - Confidential
' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.Office.Interop.Excel
<System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="",
Description:="")> _
<System.CLSCompliantAttribute(False)> _
Partial
Public Class ScriptMain
Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
Enum ScriptResults
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Enum
Public Sub Main()
        Dts.TaskResult = ScriptResults.Success
'Dim proc As System.Diagnostics.Process
'kill all instances of excel
'For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
' proc.Kill()
'Next
Dim excelnacomm As
New Microsoft.Office.Interop.Excel.Application
Dim wbnacomm As Microsoft.Office.Interop.Excel.Workbook
        wbnacomm = excelnacomm.Workbooks.Open("http://test.xlsx")(renamed
the excel)
        wbnacomm.RefreshAll()
        wbnacomm.Save()
        wbnacomm.Close()
        excelnacomm.Quit()
        Runtime.InteropServices.Marshal.ReleaseComObject(excelnacomm)
End Sub
End
Class
Please let me know what could be the reason
Smash126

The Best Answer

Advertisement
Download:
Microsoft Office 2010: Primary Interop Assemblies Redistributable
How to: Add or Remove References By Using the Add Reference Dialog Box  /  How to:
Add and Remove References in Visual Studio (C#)
Olaf Helper
[ Blog] [ Xing] [ MVP]