Solved

How to move multiple files to another folder in Access vba

Posted on 2014-09-23
3
2,146 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Setting that's causing Access to crash 19 37
Error can't find table ?? 5 28
UK Date format in MS Access 4 25
DataType for bit Comparison 11 21
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 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