Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Moving Files

I have a column with a path for every record in Column D. Example
\\TEST\MyDoc\Pic.bmp
How do I by record copy each file at the path listed to a new folder in My
Docs called (CopyData)?

Thanks,
AJ
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Moving Files

Something like this will work:

Sub test()

Dim i As Long
Dim arr

'looping through an array is a bit faster
arr = Range(Cells(4), Cells(100, 4))

For i = 1 To UBound(arr)
'this presumes the full path is in range in column D
FileCopy arr(i, 1), "C:\My Documents\CopyData\" & FileFromPath(arr(i,
1))
Next i

End Sub


Function FileFromPath(ByVal strFullPath As String, _
Optional bExtensionOff As Boolean) As String

On Error GoTo ERROROUT

FileFromPath = Right$(strFullPath, _
Len(strFullPath) - _
InStrRev(strFullPath, "\", , vbBinaryCompare))

If bExtensionOff Then
FileFromPath = Left$(FileFromPath, _
InStr(1, FileFromPath, ".", vbBinaryCompare) - 1)
End If

Exit Function
ERROROUT:

'or return the provided strFullPath
FileFromPath = vbNullString

End Function


RBS


"Aaron" wrote in message
...
I have a column with a path for every record in Column D. Example
\\TEST\MyDoc\Pic.bmp
How do I by record copy each file at the path listed to a new folder in My
Docs called (CopyData)?

Thanks,
AJ


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving files Naz Excel Programming 2 October 3rd 08 10:37 PM
moving files Donna S Excel Programming 3 May 30th 07 10:15 PM
Moving files which are linked chrismc1972 Excel Discussion (Misc queries) 1 January 23rd 07 09:28 PM
Moving files JT Excel Programming 1 August 10th 06 04:02 PM
Moving Files PraxisPete Excel Programming 3 December 1st 05 10:07 AM


All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"