Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
moving files
How do I select all files in a folder and then have it ask me where to move
them too? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
moving files
Donna,
Here's one way: Sub test() Dim strSource As String Dim strDest As String Dim strFileName As String strSource = InputBox("Enter source folder path") strDest = InputBox("Enter destination folder path") strFileName = Dir(strSource, vbDirectory) If strFileName = "" Then MsgBox "Source Folder path is invalid", vbCritical Exit Sub End If strFileName = Dir(strDest, vbDirectory) If strFileName = "" Then MsgBox "Destination Folder path is invalid", vbCritical Exit Sub End If strFileName = Dir(strSource & "\*.*") While strFileName < "" Name strSource & "\" & strFileName As strDest & "\" & strFileName strFileName = Dir Wend End Sub -- Hope that helps. Vergel Adriano "Donna S" wrote: How do I select all files in a folder and then have it ask me where to move them too? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
moving files
"Donna S" wrote:
How do I select all files in a folder and then have it ask me where to move them too? You can also use the FileSystemObject object: Sub test() Set fso = CreateObject("Scripting.FileSystemObject") strSource = InputBox("Enter source folder path") strDest = InputBox("Enter destination folder path") If Not fso.FolderExists(strSource) Then MsgBox "Source Folder path is invalid", vbCritical End If If Not fso.FolderExists(strDest) Then MsgBox "Target Folder path is invalid", vbCritical End If If Right(strDest, 1) < "\" Then strDest = strDest & "\" End If For Each file In fso.GetFolder(strSource).Files file.Move strDest Next End Sub Hope this is of some help. -- urkec |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
moving files
Vergel,
Can you help me change the macro so it doesn't ask me the source destination because my source destination will always be the same. We can call the source destination F:\Daily. I hope you can help. Thanks, Donna "Vergel Adriano" wrote: Donna, Here's one way: Sub test() Dim strSource As String Dim strDest As String Dim strFileName As String strSource = InputBox("Enter source folder path") strDest = InputBox("Enter destination folder path") strFileName = Dir(strSource, vbDirectory) If strFileName = "" Then MsgBox "Source Folder path is invalid", vbCritical Exit Sub End If strFileName = Dir(strDest, vbDirectory) If strFileName = "" Then MsgBox "Destination Folder path is invalid", vbCritical Exit Sub End If strFileName = Dir(strSource & "\*.*") While strFileName < "" Name strSource & "\" & strFileName As strDest & "\" & strFileName strFileName = Dir Wend End Sub -- Hope that helps. Vergel Adriano "Donna S" wrote: How do I select all files in a folder and then have it ask me where to move them too? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Moving files which are linked | Excel Discussion (Misc queries) | |||
Moving xls files that have links?? | Links and Linking in Excel | |||
Moving files | Excel Programming | |||
macro as and moving files | Excel Programming | |||
Moving Files | Excel Programming |