How can I rename files on the HD from Access VBA? - ADO DAO RDO RDS

This is a discussion on How can I rename files on the HD from Access VBA? - ADO DAO RDO RDS ; I'm running Access 2000. I download files for import on a dialy basis. I would like to automatically rename the files from a function in my database before importing them. The file names are always different, but they follow a ...

+ Reply to Thread
Results 1 to 3 of 3

How can I rename files on the HD from Access VBA?

  1. Default How can I rename files on the HD from Access VBA?

    I'm running Access 2000.

    I download files for import on a dialy basis. I would like to automatically
    rename the files from a function in my database before importing them.

    The file names are always different, but they follow a pattern. There are
    two files in the import directory before I run the import.

    C:\ImportData\C32-0852361-1.txt
    C:\ImportData\C32-0852361-2.txt

    The first file always starts with the letter "C" and ends with "-1.txt"

    C:\ImportData\C32-0852361-1.txt

    I want to change the file extention to "csv" - C32-0852361-1.csv

    The second file also starts with the letter "C" and it ends in "-2.txt"

    C:\ImportData\C32-0852361-2.txt

    I want to append the letter "L" to the beginning of the file name, and
    change the file extention to "csv" - LC32-0852361-2.csv

    Can someone please give me the code for this?

    Thanks in advance.

    Alan



  2. Default Re: How can I rename files on the HD from Access VBA?

    Alan
    there is a Name statement in VBA to do this.

    Name Statement Example from the vba help file.
    This example uses the Name statement to rename/move a file.
    For purposes of this example, assume that the directories or folders that
    are specified already exist.

    Dim OldName as String
    Dim NewName as String

    ' Define file names.
    OldName = "OLDFILE": NewName = "NEWFILE"
    ' Rename file.
    Name OldName As NewName

    OldName = "C:\MYDIR\OLDFILE": NewName = "C:\YOURDIR\NEWFILE"
    ' Move and rename file
    Name OldName As NewName


    Jeanette Cunningham

    "Alan B. Densky" <sales@neuro-vision.us> wrote in message
    news:lp2zj.16369$pp6.8105@bignews3.bellsouth.net...
    > I'm running Access 2000.
    >
    > I download files for import on a dialy basis. I would like to
    > automatically
    > rename the files from a function in my database before importing them.
    >
    > The file names are always different, but they follow a pattern. There are
    > two files in the import directory before I run the import.
    >
    > C:\ImportData\C32-0852361-1.txt
    > C:\ImportData\C32-0852361-2.txt
    >
    > The first file always starts with the letter "C" and ends with "-1.txt"
    >
    > C:\ImportData\C32-0852361-1.txt
    >
    > I want to change the file extention to "csv" - C32-0852361-1.csv
    >
    > The second file also starts with the letter "C" and it ends in "-2.txt"
    >
    > C:\ImportData\C32-0852361-2.txt
    >
    > I want to append the letter "L" to the beginning of the file name, and
    > change the file extention to "csv" - LC32-0852361-2.csv
    >
    > Can someone please give me the code for this?
    >
    > Thanks in advance.
    >
    > Alan
    >
    >




  3. Default Re: How can I rename files on the HD from Access VBA?

    Thanks Jeanette, I'll see what I can do with that info

    Regards
    Alan
    "Jeanette Cunningham" <nnn@discussions.microsoft.com> wrote in message
    news:uhFugfafIHA.1900@TK2MSFTNGP02.phx.gbl...
    > Alan
    > there is a Name statement in VBA to do this.
    >
    > Name Statement Example from the vba help file.
    > This example uses the Name statement to rename/move a file.
    > For purposes of this example, assume that the directories or folders that
    > are specified already exist.
    >
    > Dim OldName as String
    > Dim NewName as String
    >
    > ' Define file names.
    > OldName = "OLDFILE": NewName = "NEWFILE"
    > ' Rename file.
    > Name OldName As NewName
    >
    > OldName = "C:\MYDIR\OLDFILE": NewName = "C:\YOURDIR\NEWFILE"
    > ' Move and rename file
    > Name OldName As NewName
    >
    >
    > Jeanette Cunningham
    >
    > "Alan B. Densky" <sales@neuro-vision.us> wrote in message
    > news:lp2zj.16369$pp6.8105@bignews3.bellsouth.net...
    > > I'm running Access 2000.
    > >
    > > I download files for import on a dialy basis. I would like to
    > > automatically
    > > rename the files from a function in my database before importing them.
    > >
    > > The file names are always different, but they follow a pattern. There

    are
    > > two files in the import directory before I run the import.
    > >
    > > C:\ImportData\C32-0852361-1.txt
    > > C:\ImportData\C32-0852361-2.txt
    > >
    > > The first file always starts with the letter "C" and ends with "-1.txt"
    > >
    > > C:\ImportData\C32-0852361-1.txt
    > >
    > > I want to change the file extention to "csv" - C32-0852361-1.csv
    > >
    > > The second file also starts with the letter "C" and it ends in "-2.txt"
    > >
    > > C:\ImportData\C32-0852361-2.txt
    > >
    > > I want to append the letter "L" to the beginning of the file name, and
    > > change the file extention to "csv" - LC32-0852361-2.csv
    > >
    > > Can someone please give me the code for this?
    > >
    > > Thanks in advance.
    > >
    > > Alan
    > >
    > >

    >
    >




+ Reply to Thread