Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2005
    Posts
    9

    Unanswered: ActiveX to copy and rename file

    Hi,

    I'm looking to use ActiveX in a DTS to copy a file from on elocation to another.
    I have the code for this (attached below kindly supplied by a colleague), so that's cool.

    dim filesys
    set filesys=CreateObject("Scripting.FileSystemObject")

    If filesys.FileExists("D:\Credits\Credits_MTD.mdb") Then
    filesys.CopyFile "D:\Credits\Credits_MTD.mdb", _
    "C:\Credits\Credits_200602.mdb"
    End If

    But what I'm looking to do is go one step further.
    As you can see, it renames the file to yyyymm, but this is hard coded, and I'm looking for a coded solution so I can rename the file with yesterday's date.

    Can anybody help me please?

  2. #2
    Join Date
    Jun 2003
    Posts
    269
    declare a variable path,get year,month,day-1 from system date,concatnate all and concatnate again with ur file path.
    pass that variable.
    I love cursor,though I never use it.Cos' I dont want to misuse it.
    ----------------------------------------------

    ----cheers
    ----http://mallier.blogspot.com

  3. #3
    Join Date
    Dec 2005
    Posts
    9
    Cheers - sorry to be a apin but is it something like this:

    dim newDate
    newDate = FormatDateTime( Now()-1 , yyyymmdd )

    .....\Credits_" & NewDate & ".mdb"

    I tried that, and it came back with Path Not Found

  4. #4
    Join Date
    Jun 2003
    Posts
    269

    Thumbs up

    Quote Originally Posted by mark.mcanally
    Cheers - sorry to be a apin but is it something like this:

    dim newDate
    newDate = FormatDateTime( Now()-1 , yyyymmdd )

    .....\Credits_" & NewDate & ".mdb"



    I tried that, and it came back with Path Not Found
    Unforunatly I dont have vb platform to test it.

    create the variable first and pass that variable.


    dim path
    path="C:\Credits\Credits_"&NewDate&".mdb"
    filesys.CopyFile "D:\Credits\Credits_MTD.mdb", path
    I love cursor,though I never use it.Cos' I dont want to misuse it.
    ----------------------------------------------

    ----cheers
    ----http://mallier.blogspot.com

  5. #5
    Join Date
    Dec 2005
    Posts
    9
    Cheers,
    Will try that now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •