Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTS create filename on the fly

Status
Not open for further replies.

camy123

Programmer
Mar 5, 2004
171
0
0
GB
hi im running a DTs package where i would like to create a excel filename on the fly(using Date) cuurently i just have a default filename and then rename it but it doesnt work ne one know why please

Function Main()


Dim FileDate
Dim DateString
Dim FSO
Dim File


FileDate = Date
DateString = DatePart("yyyy",FileDate) & Right("0" & _
DatePart("m",FileDate), 2) & Right("0" & DatePart("d",FileDate), 2)

Set FSO = CreateObject("Scripting.FileSystemObject")
Set File = FSO.GetFile("G:\England Marketing\Achiever_Reporting\counts_report.xls")

DTSDestination("colname") = DTSSource("colname")
DTSDestination("Total") = DTSSource("Total")


File.Name = "counts_report_" & DateString & ".xls"


Main = DTSTaskExecResult_Success
 
Is this an ActiveX task or transformation? Seems to be a task, so I don't get the lines:
DTSDestination("colname") = DTSSource("colname")
DTSDestination("Total") = DTSSource("Total")

Anyway, try this out:
Code:
Function Main()

Dim FileDate
Dim DateString
Dim FSO 
Dim File

        
FileDate = Date 
DateString = DatePart("yyyy",FileDate) & Right("0" & _
    DatePart("m",FileDate), 2) & Right("0" & DatePart("d",FileDate), 2)

Set FSO =  CreateObject("Scripting.FileSystemObject")
[s]Set File = FSO.GetFile("G:\England Marketing\Achiever_Reporting\counts_report.xls")[/s]

File = "G:\England Marketing\Achiever_Reporting\counts_report_" & DateString & ".xls"

fso.MoveFile "G:\England Marketing\Achiever_Reporting\counts_report.xls", File

[s]DTSDestination("colname") = DTSSource("colname")
DTSDestination("Total") = DTSSource("Total")[/s]

[s]File.Name = "counts_report_" & DateString & ".xls"[/s]

Main = DTSTaskExecResult_Success

--John [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top