Solved

How to move multiple files to another folder in Access vba

Posted on 2014-09-23
3
1,970 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
ID: 40340036
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
ID: 40340129
Perfect!  Works very nice, THANK YOU!
0
 
LVL 12

Expert Comment

by:danishani
ID: 40340148
Glad to help! :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

895 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

16 Experts available now in Live!

Get 1:1 Help Now