Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How about:
Option Explicit Sub testme() Dim FinalFolderName As String Dim CurrentFolderName As String Dim FSO As Scripting.FileSystemObject Dim FinalFolder As Scripting.Folder Dim CurrentFolder As Scripting.Folder Dim myFile As Scripting.File FinalFolderName = "C:\Closing" CurrentFolderName = "C:\Assets" Set FSO = New Scripting.FileSystemObject If FSO.FolderExists(CurrentFolderName) = False _ Or FSO.FolderExists(FinalFolderName) = False Then MsgBox "where are they???" Exit Sub End If Set CurrentFolder = FSO.GetFolder(CurrentFolderName) Set FinalFolder = FSO.GetFolder(FinalFolderName) For Each myFile In CurrentFolder.Files myFile.Copy Destination:=FinalFolder.Path & "\" & myFile.Name, _ overwritefiles:=True myFile.Delete Next myFile End Sub This code requires a reference to the "Microsoft Scripting Runtime" (tools|References inside the VBE). If you're new to macros, you may want to read David McRitchie's intro at: http://www.mvps.org/dmcritchie/excel/getstarted.htm Ryan wrote: I am trying to set up a way to move files from one folder to another. I found on this board an excellent way to move a file from one folder to another using the "Name" function, but this doesn't exactly work for my situation. I am not going to know the name of all of the files in a certain folder, I will only know the folder names. Is there a way to move all of the contents from the "Assets" file to the "Closing" file without just changing the name of the file? Ryan -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Folder Contents to Excel | Excel Discussion (Misc queries) | |||
Listing the contents of a folder | Excel Discussion (Misc queries) | |||
Macro to remove contents of cell and move all other contents up one row | Excel Discussion (Misc queries) | |||
When I move scroll bar in excell the contents do not move with it | Excel Discussion (Misc queries) | |||
Move file to different folder | Excel Programming |