• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need advise on how to copy a file based on last modified date

Stewartthebrew

New Member
Hello all,

Background: I have several different invoices placed in five different folders , each week those invoices will be updated by our finance department, and saved under the same name.

The issue :The issue is all the files always saved under different extensions, for example,
file1_060920158686, next week the file will be updated to file1_061620158466, and those files are saved on a sharepoint site.

Questions :I found a code from another forum that allow me to copy the files to a shared folder, is there a way that will allow me to search the file by the last modified date, then copy the file by its last modified date, and place it in the shared folder?
How can I implement a code that will continuously loop until all the files from different network folders on that sharepoint site are all copied to my hard drive?

Here is the code I found from another forum.

Code:
Option Explicit

Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
  "URLDownloadToFileA" ( _
  ByVal pCaller As Long, ByVal szURL As String, _
  ByVal szFileName As String, _
  ByVal dwReserved As Long, _
  ByVal lpfnCB As Long) As Long


Sub DownloadFileFromWeb()
Dim i As Integer

Const strUrl As String = "http://teams/Dept/Shared Documents/Reports/Pivot_Source_Data/filename.csv"
Dim strSavePath As String
Dim returnValue As Long

strSavePath = "C:\Reports\Pivot_Source_Data\xxxxxxxx.CSV"
returnValue = URLDownloadToFile(0, strUrl, strSavePath, 0, 0)

End Sub

Thanks in advance
 
Last edited by a moderator:
Hi,

Welcome to the forum!!

Pls always tag ur codes [i did].

Are u looking that copy all the files which are modified today or

which files having the name like as "1_"<>month<>today-1<>year
 
Back
Top