• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 520
  • Last Modified:

SQL Server 2000 DTS Package Active X Script Question

I'm trying to incorporate a piece of code that I got from a different post on this site.  It deletes rows from a worksheet within an excel workbook.  The piece of code that is giving me problems is:
line 10:  SetxlWb=xlApp.Workbooks.Open(DTSGlobalVariables("\\corp\report.xls").Value)
It says:
Error Source : Microsoft Excel
Error Description: Error Code 0
Error Source: Microsoft Excel
Error Description:  " Cannot be found.  Check the spelling of the file name and verify that the file location is correct.
 When I copy the path and put it into explorer the file opens right up.  Does anyone see something below that I'm doing incorrectly?  Thanks much for your help.  

'  Visual Basic ActiveX Script

Function Main()

Dim xlApp, xlWb, xlWs, pkg
Set pkg = DTSGlobalVariables.Parent

Set xlApp = CreateObject("Excel.Application")
Set xlWs = xlWb.Worksheets("New_Table")
xlWb.Close True
set xlWs = Nothing
Set xlWb = Nothing
Set xlApp = Nothing

Set pkg = Nothing

End Function
1 Solution
it looks like you are trying to pass the value of the variable rather than the variable itself.
either hardcode it

or if you want to pass the value from a DTS global variable, create the DTS variable say
and give it the value "\\corp\report.xls"
or if you want to assign the variable from a parameter in your active x script:
DTSGlobalVariables("myExcelFile").Value = someParameter etc

then in your code:

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now