Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to move multiple files to another folder in Access vba

Posted on 2014-09-23
3
Medium Priority
?
2,613 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
danishani earned 2000 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

660 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