rename text file

barlee

Registered User.
Local time
Today, 10:15
Joined
Nov 18, 2006
Messages
30
I want to rename a text file after I have uploaded it to my database, adding a date variable.

In other words, the file C:\myfile.txt needs to be renamed C:\myfile_mmyyy.txt .

is there a way to write a quickie module that will do this, that I can add to my macro that imports the C:\myfile.txt into the db and does whatever it needs to do.....

hope that makes sense.
 
vba command NAME

NAME oldfile newfile

bit of string manipulation to insert the date - note you have to use - as / is illegal char in filenames
 
I tried that name oldname newname but I can't get it to work.

name "C:\myfile.txt" "C:\myfile_032009.txt"

either gives me an error sez Expected:end of statement or gives me a bright yellow highlight over the whole light...

it shouldn't matter if the path is a network drive versus a local drive should it...??
 
I have tried it like that as well.....I am not having any luck. As I said, I either get a syntax error, or I get yellow highlight over the line.....
 
ok, so apparently Access likes to think things over before agreeing to function according to code.....

my function

Name "J:\Reports\CS1257Detail.txt" As "J:\Reports\CS1257Detail" & Format(Date, "mmmyyyy") & ".txt"

worked just fine today......although I thought I was going to have to throw my PC out the window last night.....go figure...

thanks for the responses from those that helped....
 
And who said the search button didnt work, it does wonders!
 

Users who are viewing this thread

Back
Top Bottom