Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy a file

Status
Not open for further replies.

destini

IS-IT--Management
Jun 23, 2003
32
0
0
US
I am new to VB and I'm trying to rename a file and the file will always have yesterdays date such as DailyFile#R0906. Here is what I am using but I'm unsure how to find the correct file to rename.

FileName = "F:\DAILYFILE#R & Format(Date -1, "mmdd")
NewFileName = "F:\R347" & Format(Date -1, "mmdd")
Name FileName As NewFileName
 
looks fine to me - what issue are you having ?

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
The file is not renaming. I just wanted to be sure the syntax was correct.
 

Did you check the file names?
Code:
FileName = "F:\DAILYFILE#R & Format(Date -1, "mmdd")
NewFileName = "F:\R347" & Format(Date -1, "mmdd")
[blue]
Debug.Print FileName
Debug.Print NewFileName
[/blue]
Name FileName As NewFileName
Also, you may check if FileName does exist.

Have fun.

---- Andy
 
What about replacing this:
FileName = "F:\DAILYFILE#R & Format(Date -1, "mmdd")
with this ?
FileName = "F:\DAILYFILE#R" & Format(Date -1, "mmdd")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Just curious, why didn't this produce an error?

Code:
FileName = "F:\DAILYFILE#R & Format(Date -1, "mmdd")
 





Just sees an error and never checks to see WHERE the error is occuring, just throws up hands, and yells for help.

Skip,
[sub]
[glasses] When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd! and
Many are Cold, but Few are Frozen![tongue][/sub]
 
I guess the point of mscallisto's post was...why did the OP not mention this? They should have had the VBA parser "throws up hands, and yells for help".

Getting a "what the heck are you doing?" message is a LOT different than
The file is not renaming. I just wanted to be sure the syntax was correct.
Well....actually, no, the syntax is not correct. Which should most likely have been mentioned.


Yes, true, "the file is not renaming". BUT you are getting a syntax error!

faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top