• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1131
  • Last Modified:

Access 2010: VBA code to copy a file from one location to another.

A have a report that is exported from access and I need the code that will copy and rename the file to another location. Something like this maybe?

Copy FilePath1 to FilePath2
Name FilePath2 As FilePathNew
0
JAMES125
Asked:
JAMES125
  • 2
1 Solution
 
NorieData ProcessorCommented:
The 2nd one is correct, but you need to include the full path(s) and filename(s).
0
 
JAMES125Author Commented:
Well I need to copy it first, and then rename it because the original file needs to stay in the original location.  So what is the proper syntax to copy a file from one directory to another?
0
 
Rey Obrero (Capricorn1)Commented:
if you want to copy and retain the original, use

FileCopy FilePath1, FilePath2

if you want to move and rename the file, use

Name FilePath2 As FilePathNew
0
 
NorieData ProcessorCommented:
Oops, my mistake

Name is used to rename/move a file, not copy it.

The VBA for copying  a file is FileCopy.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now