Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2785
  • Last Modified:

How to move multiple files to another folder in Access vba

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
TechGuise
Asked:
TechGuise
  • 2
1 Solution
 
danishaniCommented:
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
 
TechGuiseAuthor Commented:
Perfect!  Works very nice, THANK YOU!
0
 
danishaniCommented:
Glad to help! :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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