View Full Version : Solved: Moving all files from one folder to another
satyen
04-16-2008, 01:05 PM
Hello.
I have a a macro that will be run. After it has actioned what it needs to I need to move the contents of a folder to another folder using VBA.
Can someone please help?
dominicb
04-16-2008, 02:41 PM
Good evening satyen
No specifics here, so it'll have to be a general answer I'm afraid. The code below will move MyFile.xls from C:\ to C:\New Folder.
Sub test()
Name "C:\MyFile.xls" As "C:\New Folder\MyFile.xls"
End Sub
HTH
DominicB
mdmackillop
04-16-2008, 02:54 PM
For all files in a folder
Sub MoveFiles()
Dim MyFile As String
MyFile = Dir("C:\AAAA\*.*")
Do Until MyFile = ""
Name "C:\AAAA\" & MyFile As "C:\AAA\" & MyFile
MyFile = Dir
Loop
End Sub
satyen
04-16-2008, 02:56 PM
I will try this code thanks.!
satyen
04-16-2008, 03:03 PM
Thanks works a marvel! How do I add a warning to say there are no files if no files exist
mdmackillop
04-16-2008, 03:24 PM
Create a messagebox if MyFile = ""
satyen
04-16-2008, 03:29 PM
Thanks. Works a treat!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.