Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Export to Excel file

Author  Topic 

sagarpbora
Starting Member

12 Posts

Posted - 2007-04-05 : 04:42:15

Hi all,

I am working on exporting data to an excel file through DTS export. I have created a DTS package which exports the data to an excel file. The export works fine. But, after exporting, I am supposed to move the file to a different location. I have written a VBScript to move the file.

The problem is that, If I execute the script after creating/populating the excel file(On Completion), it throws an error "Permission Denied"

But, if I execute the script independantly, i.e. creating a different package for the script, then it works fine and file gets moved to the specified location.

I also tried using the "Package Execution Task". I attached this new package to the existing package(which populates excel file). But still I am getting the same error "Permission Denied"

Can anybody suggest a solution for it?

For reference, please find the script below.


'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************

Function Main()

dim objFSO
dim fileName
Const OverwriteExisting = True

fileName = "D:\test_"
fileName = fileName & Day(Date) & "_"
fileName = fileName & Month(Date) & "_"
fileName = fileName & Year(Date) & "_"
fileName = fileName & Hour(Now) & "_"
fileName = fileName & Minute(Now) & "_"
fileName = fileName & Second(Now) & ".xls"

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Test.xls" , fileName, OverwriteExisting

msgbox fileName
objFSO.DeleteFile "C:\Test.xls", True' On this line, I am getting error

Main = DTSTaskExecResult_Success

End Function

   

- Advertisement -