Solved

How to move multiple files to another folder in Access vba

Posted on 2014-09-23
3
1,871 Views
Last Modified: 2014-09-23
Will the NAME method described by Jeffrey Coachman in the below question work somehow for with a wildcard?

http://www.experts-exchange.com/Database/MS_Access/Q_23701586.html#a22384714

This is what I'm trying
   Name stExportPath & "*.csv" As stExportArchivePath & "*.csv"

I've used debug.print to look at the two paths and they seem correct (they include the last "\")


in the past I've used something close to the following, but I can't find it and can't get it to work either.
fso.MoveFile (stExportPath & "*.csv"), stExportArchivePath

Thanks
0
Comment
Question by:TechGuise
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
danishani earned 500 total points
Comment Utility
I did something similar in the past and used to loop through the filenames and look for the file extension.

Something like this:
Dim FSO As Object
     Dim FromPath As String
     Dim ToPath As String
     Dim FileInFromFolder As Object
     
     On Error GoTo ErrHandler
     
     FromPath = "C:\Temp\"
     ToPath = "C:\Temp\test\"

     Set FSO = CreateObject("scripting.filesystemobject")


     For Each FileInFromFolder In FSO.getfolder(FromPath).Files
        If Right(FileInFromFolder.Name, 3) = "csv" Then
            FileInFromFolder.Move ToPath
         End If
     Next FileInFromFolder

Open in new window


Hope this helps,
Daniel
0
 

Author Closing Comment

by:TechGuise
Comment Utility
Perfect!  Works very nice, THANK YOU!
0
 
LVL 12

Expert Comment

by:danishani
Comment Utility
Glad to help! :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now