troubleshooting Question

How to move a File using VBA

Avatar of juricta
jurictaFlag for United States of America asked on
Microsoft AccessVBA
4 Comments1 Solution660 ViewsLast Modified:
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
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros