By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,641 Members | 2,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,641 IT Pros & Developers. It's quick & easy.

Code problem on find/copy files

P: 34
Hi All,

I am having problems with the below code, it was working but as soon as I included the formatted dates as part of the file path the code now by passes the Dir$ and Ends the Sub - anyone know whats going worng please

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Command0_Click()
  3.  
  4. Dim Fdate As String
  5. Dim Fdate1 As String
  6. Dim Fdate2 As String
  7. Dim S As String
  8.  
  9.  
  10. Fdate = Year(Date)
  11. Fdate1 = Format(Date, "yyyy-mmm")
  12. Fdate2 = Format(LastWorkingDay, "yyyymmdd")
  13.  
  14. S = Dir$("\\path1\path2\path3\GEDDSupport\Live\Ronnie2\ "& Fdate "\" & Fdate1 "\" & Fdate2" \*.pny.Prophet9")
  15. Do While Len(S) > 0
  16.   FileCopy "\\path1\path2\path3\GEDDSupport\Live\Ronnie2\" & Fdate" \" & Fdate1" \" & Fdate2" \" & S, "\\path4\path5\path6\Recs and Control\NY_Prophet.txt"
  17.   S = Dir$
  18.  Loop
  19. End Sub
  20.  
  21.  
Thanks
Nigel
Mar 2 '10 #1
Share this Question
Share on Google+
1 Reply


P: 34
Sorry all - I have now fixed this, I combined the dates first as
test = Fdate & "\" & Fdate1 & "\" & Fdate2 and then called test within the file path.

Thanks
Mar 2 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.