File Move

mitch26

New Member
Joined
Nov 3, 2005
Messages
4
I need to move 8 file from different locations, to one location once a week. I want to wright a script to do this once a week at a certain time if the files are up to date. I know its possible, but I am not that good with coding. Please let me know if you have anything. Thank you (MITCH :cool: )
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Excel?

Hi Mitch,

wouldn't it be easier to write a .bat file to do that for you? That's at least what I'm using for that kind of job, with commands like:
copy "c:\temp\blabla.xls" "d:\mydir" /d /y

But otherwise, in the VBA-help there are the items "CopyFile", "MoveFile" and "FileSystemObject", could be handy if you want to copy the files from several locations to 1. As a nice startup, I put some code below,

Koen

Code:
Sub Main()
    
    Dim oFSO
    Dim oFile
    Dim sSourceFile
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    sSourceFile = "C:\temp\Member list.pdf"
    Set oFile = oFSO.GetFile(sSourceFile)
        
    If oFile.Datelastmodified < Date - 3 Then
        'Older then 3 days
    Else
        oFSO.CopyFile sSourceFile, "D:\blabla.pdf"
    End If

    ' Clean Up
    Set oFile = Nothing
    Set oFSO = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,206,833
Messages
6,075,128
Members
446,123
Latest member
junkyardforme

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top