Solved

SQL Server 2000 DTS Package Active X Script Question

Posted on 2008-06-25
1
502 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 500 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.

685 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