Avatar of juricta
Flag for United States of America

asked on 

How to move a File using VBA

I have code (using VBA Access 2010) that checks to see if a File exists (it works). If the File exists I need to rename it and MOVE it to a local location.  

In the code below the NEW file name is newpriceMonthYear where vMonthYear (for October) would be 102017.txt and the new file name will be "newprice102017.txt".  Creating vMonthYear  works. vMonthYear is Dim'd as a STRING  The code executes with no errors but the File is NOT moved

Dim FSO As FileSystemObject
FileToMove = "C:\RDC-POS\OLCC Downloads\newprice.txt"
DestPath = "C:\RDC-POS\OLCC Past Downloads\newprice" & vMonthYear
FSO.MoveFile FileToMove, DestPath
Microsoft AccessVBA

Avatar of undefined
Last Comment

8/22/2022 - Mon