|
-
May 3rd, 2005, 10:39 PM
#1
Thread Starter
New Member
Visual Basic Active X Rename Question
New to Active X and Visual Basic, trying to get a grip on the coding. Below is what I have come up with to rename a .csv file to have the date appended to the end of it. The scipt says sucessful after running but the file name isn't changing, what I am missing. Thanks in advance for any replies!
Function Main()
Dim FDate
Dim DString
Dim objFSO
Dim File_XYT
FDate = Date
DString = DatePart("yyyy",FDate) & Right("0" & _
DatePart("m",FDate), 2) & Right("0" & DatePart("d",FDate), 2)
Set objFSO = CreateObject("Scripting.FileSystemObject")
File_538 = "\\PayrollFiles\ADPData\FTM (XYT)\PRXYTEMP"
If objFSO.FileExists(File_XYT) Then
File_XYT.Name = "PRXYTEMP" & DString & ".csv"
else
Main = DTSTaskExecResult_Failure
End If
Main = DTSTaskExecResult_Success
End Function
-
May 3rd, 2005, 10:44 PM
#2
Lively Member
Re: Visual Basic Active X Rename Question
What is File_XYT? A string?
File_538 = "\\PayrollFiles\ADPData\FTM (XYT)\PRXYTEMP
What is File_538?
Why don't u use s/t like this?
VB Code:
Name File_XYT As DString & ".csv"
-
May 3rd, 2005, 11:06 PM
#3
Thread Starter
New Member
Re: Visual Basic Active X Rename Question
Well I re-worked and got the date to go to the end of the file on the Move, but in a perfect world it should be at the start IE 05052005PRXYTEMP.csv
But can't get it to write there, any suggestions.
Function Main()
Dim FDate
Dim DString
Dim oFSO
Dim sSourceFile
Dim sDestinationFile
FDate = Date
DString = DatePart("yyyy",FDate) & Right("0" & _
DatePart("m",FDate), 2) & Right("0" & DatePart("d",FDate), 2)
Set oFSO = CreateObject("Scripting.FileSystemObject")
sSourceFile = "D:\PayrollFiles\ADPData\PRXYTEMP.csv"
sDestinationFile = "D:\PayrollFiles\ADPData\FTM (XYT)\PRXYTEMP"& dstring &".csv"
oFSO.MoveFile sSourceFile, sDestinationFile
' Clean Up
Set oFSO = Nothing
Main = DTSTaskExecResult_Success
End Function
-
May 3rd, 2005, 11:12 PM
#4
Re: Visual Basic Active X Rename Question
VB Code:
sDestinationFile = "D:\PayrollFiles\ADPData\FTM (XYT)\PRXYTEMP"& dstring &".csv"
should be
VB Code:
sDestinationFile = "D:\PayrollFiles\ADPData\" & dstring &
"FTM (XYT)\PRXYTEMP.csv"
-
May 3rd, 2005, 11:13 PM
#5
Lively Member
Re: Visual Basic Active X Rename Question
Try this:
VB Code:
sDestinationFile = "D:\PayrollFiles\ADPData\FTM (XYT)\" & dstring & "PRXYTEMP.csv"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|