View Single Post
 
Old 04-06-2012, 03:46 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,355
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Greg,

Try something like:
Code:
Option Explicit
Dim StrIO As String
Sub BulkCopier()
Application.ScreenUpdating = False
Dim strInFolder As String, strOutFolder As String
Dim strInFile As String, strOutFile As String
Dim StrPrefix As String
StrIO = "Choose an INPUT folder"
strInFolder = GetFolder
If strInFolder = "" Then Exit Sub
StrIO = "Choose an OUTPUT folder"
strOutFolder = GetFolder
If strOutFolder = "" Then Exit Sub
StrPrefix = "\" & Split(strInFolder, "\")(UBound(Split(strInFolder, "\"))) & "_"
strInFile = Dir(strInFolder & "\*.doc", vbNormal)
While strInFile <> ""
  On Error Resume Next
  FileCopy strInFolder & "\" & strInFile, strOutFolder & StrPrefix & strInFile
  strInFile = Dir()
Wend
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, StrIO, 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
You'll get prompted to select the input and output folders. The macro will copy all files from the input folder to the output folder, prefixing them with the input folder's name.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote