UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Copy Files Based On Last Modified Date And Time, Access 2013    
 
   
g0049978
post Sep 17 2019, 04:08 PM
Post#1



Posts: 26
Joined: 13-September 19



I want my code to look at the prior 2 days and copy any files from the SharePoint directory that was last modified in the hour of 5am.

Here is my code that copies all the files from the prior 2 days and it works but I only need the file(s) that were modified in the 5am hour:

Public Sub copyshare()


Dim fileSystem, folder, file
Dim path

path = "\\sharepoint.abc.com@SSL\DavWWWRoot\sites\FIS\staffing\Shared Documents\Staffing Open Cases by Bucket\"

Set fileSystem = CreateObject("Scripting.FileSystemObject")
Set folder = fileSystem.GetFolder(path)

For Each file In folder.Files


If DateDiff("d", file.DateLastModified, Now) < 2 Then

fileSystem.CopyFile "\\sharepoint.abc.com@SSL\DavWWWRoot\sites\FIS\staffing\Shared Documents\Staffing Open Cases by Bucket\" & file.Name, "c:\users\Public\Sources\"

MsgBox (file.Name & " last modified at " & file.DateLastModified)
End If
Next

End Sub
Go to the top of the page
 
theDBguy
post Sep 17 2019, 05:10 PM
Post#2


Access Wiki and Forums Moderator
Posts: 76,416
Joined: 19-June 07
From: SunnySandyEggo


Hi. You could play with this piece of code:
CODE
If Hour(FileDateTime(file.Name)) = 5 Then
(untested)

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
g0049978
post Sep 18 2019, 08:53 AM
Post#3



Posts: 26
Joined: 13-September 19



Thank you - that works great -

final solution is If DateDiff("d", file.DateLastModified, Now) < 1 And Hour(file.DateLastModified) = 5 Then

Is there a way to pull the file only if the file name has "6am" within it?
Go to the top of the page
 
g0049978
post Sep 18 2019, 09:04 AM
Post#4



Posts: 26
Joined: 13-September 19



This worked:) If DateDiff("d", file.DateLastModified, Now) < 1 And file.Name Like "*8am.xlsx" Then
Go to the top of the page
 
theDBguy
post Sep 18 2019, 09:54 AM
Post#5


Access Wiki and Forums Moderator
Posts: 76,416
Joined: 19-June 07
From: SunnySandyEggo


Hi. Glad to hear you got it sorted out. Good luck with your project.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    21st October 2019 - 10:29 PM