Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Server 2000 DTS Package Active X Script Question

Posted on 2008-06-25
1
Medium Priority
?
519 Views
Last Modified: 2013-11-30
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")
SetxlWb=xlApp.Workbooks.Open(DTSGlobalVariables("\\corp\report.xls").Value)
Set xlWs = xlWb.Worksheets("New_Table")
xlWs.Rows.Delete
xlWb.Close True
set xlWs = Nothing
Set xlWb = Nothing
xlApp.Quit
Set xlApp = Nothing

Set pkg = Nothing

End Function
0
Comment
Question by:rsmuckles
1 Comment
 
LVL 19

Accepted Solution

by:
frankytee earned 2000 total points
ID: 21870916
>SetxlWb=xlApp.Workbooks.Open(DTSGlobalVariables("\\corp\report.xls").Value)
it looks like you are trying to pass the value of the variable rather than the variable itself.
either hardcode it
SetxlWb=xlApp.Workbooks.Open("\\corp\report.xls")

or if you want to pass the value from a DTS global variable, create the DTS variable say
"myExcelFile"
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:
SetxlWb=xlApp.Workbooks.Open(DTSGlobalVariables("myExcelFile").Value)
etc
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question