copy Julian dated folder

  • Thread starter Thread starter Shawn
  • Start date Start date
S

Shawn

Hello,
I have database witch create fold each day by Julian date, for example
“SMP09002†folder name year and day folder name does not change. User
manually copy files to different drive folder and import to access db. Is
their any way I can automate that process. I tried FileCopy method but I am
getting error message “File path not foundâ€.
Here is the code:

StrFolder = ("smp" & Format(Now(), "yy") & Format(Now(), "y"))

FileCopy "S:\Remitance\TAB\" & StrFolder & "\Trans\AAB.001",
"C:\DATA\AAB.001"

Any help would be most appreciated

Regards,
 
Assuming today's date (January 16), your code tries to copy
"S:\Remitance\TAB\smp09016\Trans\AAB.001" to "C:\DATA\AAB.001".

Does folder C:\Data exist? Does the user have the necessary permissions on
it? (For that matter, is "S:\Remitance\TAB\smp09016\Trans\" the correct
folder name: no typos or anything like that?)
 
Thanks for prompt respons . Yes "C:\data" does exist there is no typo or any
thing
If I use code without expression it does copy the file on "C:\data" folder.
Example "S:\Remitance\TAB\smp09016\Trans\AAB.001" to "C:\DATA\AAB.001".
with expression gives me error "File path not found".

Thanks againg for helping me
 
You may need to verify that the file you're trying to copy exists:

StrFolder = ("smp" & Format(Now(), "yy") & Format(Now(), "y"))

If Len(Dir("S:\Remitance\TAB\" & StrFolder & "\Trans\AAB.001")) > 0 Then
FileCopy "S:\Remitance\TAB\" & StrFolder & "\Trans\AAB.001",
"C:\DATA\AAB.001"
Else
MsgBox "S:\Remitance\TAB\" & StrFolder & "\Trans\AAB.001 doesn't exist."
End If
 
Thank you, I think problem I having in my expression. If today is Jan 1st
“Expression converts "StrFolder = ("smp" & Format(Now(), "yy") &
Format(Now(), "y"))" date to “SMP091“instead of “SMP09001†format date
display day digit only.
 
Try

StrFolder = "smp" & Format(Date(), "yy") & Format(DatePart("y", Date()),
"000")
 
Back
Top