Results 1 to 5 of 5

Thread: Visual Basic Active X Rename Question

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2005
    Location
    USA
    Posts
    2

    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

  2. #2
    Lively Member
    Join Date
    Apr 2005
    Posts
    68

    Re: Visual Basic Active X Rename Question

    Dim File_XYT
    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:
    1. Name File_XYT As DString & ".csv"

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2005
    Location
    USA
    Posts
    2

    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

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Visual Basic Active X Rename Question

    VB Code:
    1. sDestinationFile = "D:\PayrollFiles\ADPData\FTM (XYT)\PRXYTEMP"& dstring &".csv"

    should be
    VB Code:
    1. sDestinationFile = "D:\PayrollFiles\ADPData\" & dstring &
    2. "FTM (XYT)\PRXYTEMP.csv"

  5. #5
    Lively Member
    Join Date
    Apr 2005
    Posts
    68

    Re: Visual Basic Active X Rename Question

    Try this:
    VB Code:
    1. 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
  •  



Click Here to Expand Forum to Full Width