DTS Export to a Specific Named Range in Excel

  • Hi, I'm trying to export data to export data from a sql query to a specific location in Excel. I've tried doing the drop and recreate sheet with a SQL task but it always appends the new rows at the end of where the old rows stopped. I'm trying to think of a different approach now and am trying out activex. Does anyone know if this can even be accomplished? I know that it can be done through VB so I thought that it should probably work with ActiveX as well. Here's my code...

    Function Main()

      Dim e_app

      Dim e_wbook

      Dim e_wksheet

      Dim e_range

      Set e_app = CREATEOBJECT("Excel.Application")

      Set e_wbook = e_app.Workbooks.Open(DTSGlobalVariables("globalvariable1").Value)

      Set e_wksheet = e_wbook.Worksheets(DTSGlobalVariables("globalvariable2").Value)

      e_wksheet.RANGE("A2").Paste(DTSSource("Column1"))

      e_wbook.Save

      e_wbook.Close

      e_app.Quit

      Set e_wbook = Nothing

      Set e_app = Nothing

     Main = DTSTransformStat_OK

    End Function

    Not even sure if I'm on the right page here but any help would be greatly appreciated.

    Thank you.

  • .RANGE expects (CELL1, CELL2)....  Have you tried .CELLS("A2") ???



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • What exactly are you trying to do? If you are looking to export a single value to a cell you can use:

    e_wksheet.Cells(1,1).Value = yourvalue

    Or are you are looking to insert a complete column?


    ------------------------------
    The Users are always right - when I'm not wrong!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply