P
Paul B
I have a list of picture names in a sheet named Search Results, Column C,
starting in C2, like DSCF0001, DSCF0002, ... that I want to copy them from
one directory to another directory, I have some code that will copy ALL the
pictures in the directory to the other one but how can I only copy the files
that are in column C. Here is the code to copy them all.
Thanks
Option Explicit
Sub CopyPictures()
Dim WSHShell As Object
Dim DesktopPath As String
Dim sSource As String
Dim sDestination As String
Dim fs As Object
Set WSHShell = CreateObject("WScript.Shell")
DesktopPath = WSHShell.SpecialFolders("Desktop")
Set WSHShell = Nothing
'Checks to make sure you have the carousels folder
If Dir(Application.DefaultFilePath & "\My Pictures\Carousels\") =
vbNullString Then
MsgBox "Can Not Fine The Directory" & Application.DefaultFilePath & "\My
Pictures\Carousels", , "Directory Error"
Exit Sub
End If
'checks to see if you have the Copy of Carousels folder on your desktop
'if not it will be made
If Dir(DesktopPath & "\Copy of Carousels", vbDirectory) = vbNullString Then
MkDir DesktopPath & "\Copy of Carousels"
'use if you only want jpg files
'sSource = Application.DefaultFilePath _
& "\My Pictures\Carousels\*.jpg"
'use to get all files
sSource = Application.DefaultFilePath _
& "\My Pictures\Carousels\*"
'the destination folder
sDestination = DesktopPath & "\Copy of Carousels"
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile sSource, sDestination
End Sub
starting in C2, like DSCF0001, DSCF0002, ... that I want to copy them from
one directory to another directory, I have some code that will copy ALL the
pictures in the directory to the other one but how can I only copy the files
that are in column C. Here is the code to copy them all.
Thanks
Option Explicit
Sub CopyPictures()
Dim WSHShell As Object
Dim DesktopPath As String
Dim sSource As String
Dim sDestination As String
Dim fs As Object
Set WSHShell = CreateObject("WScript.Shell")
DesktopPath = WSHShell.SpecialFolders("Desktop")
Set WSHShell = Nothing
'Checks to make sure you have the carousels folder
If Dir(Application.DefaultFilePath & "\My Pictures\Carousels\") =
vbNullString Then
MsgBox "Can Not Fine The Directory" & Application.DefaultFilePath & "\My
Pictures\Carousels", , "Directory Error"
Exit Sub
End If
'checks to see if you have the Copy of Carousels folder on your desktop
'if not it will be made
If Dir(DesktopPath & "\Copy of Carousels", vbDirectory) = vbNullString Then
MkDir DesktopPath & "\Copy of Carousels"
'use if you only want jpg files
'sSource = Application.DefaultFilePath _
& "\My Pictures\Carousels\*.jpg"
'use to get all files
sSource = Application.DefaultFilePath _
& "\My Pictures\Carousels\*"
'the destination folder
sDestination = DesktopPath & "\Copy of Carousels"
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile sSource, sDestination
End Sub