title: Copy information from a Excel file to another Excel file using SSIS VB2010, What wrong with these code
body: <p>I am making an SSIS that will:</p>
  
  <ol>
  <li>Copy data from SQL Server SQL to Excel file</li>
  <li>Then from the Excel File into a another preexisting Excel file with some formulas</li>
  </ol>
  
  <p>I did the  first part --Copy from SQL to <em>Excel1-</em>-  which works fine. Then I tried to copy from the <em>Excel1</em> file to the other using script task in Visual Basic 2010. </p>
  
  <p>I want to somebody to check this program and tell me what is wrong with it in trying to copy information from a <em>Excel1</em> to a <em>Excel2</em>. When I executed I get the error <code>DTS scrip Task Runtime Error</code> and it does nothing.</p>
  
  <pre><code>Public Sub Main()
      Dim oExcel As Microsoft.Office.Interop.Excel.Application,
          oExel2 As Microsoft.Office.Interop.Excel.Application
  
      Dim Obook As Microsoft.Office.Interop.Excel.Workbook,
          Obook2 As Microsoft.Office.Interop.Excel.Workbook,
          Osheet As Microsoft.Office.Interop.Excel.Worksheet,
          Osheet2 As Microsoft.Office.Interop.Excel.Worksheet
  
      'Programing
  
      'From  Excel Spreadsheet
  
      oExcel = New Microsoft.Office.Interop.Excel.Application()
      oExcel.Visible = False
      Obook = New Microsoft.Office.Interop.Excel.Workbook("C:\Documents\AT1.xls")
      Osheet = DirectCast(Obook.Sheets("Sheet1"), Microsoft.Office.Interop.Excel.Worksheet)
  
  
      'To Excel Spreadsheet
  
      oExel2 = New Microsoft.Office.Interop.Excel.Application()
      oExel2.Visible = False
      Obook2 = New Microsoft.Office.Interop.Excel.Workbook("C:\Documents\A2.xls")
      Osheet2 = DirectCast(Obook2.Sheets("January"), Microsoft.Office.Interop.Excel.Worksheet)
  
      Osheet2.Range("B11", "R16").Value = Osheet.Range("A3", "Q8").Value
  
      'Close 
  
      Osheet = Nothing
      Obook.Close(False)
      oExcel.Quit()
  
      Osheet2 = Nothing
      Obook.Close(False)
      oExel2.Quit()
  
      Dts.TaskResult = ScriptResults.Success
  
   End Sub
  </code></pre>