Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

resize an image stored in a folder

$
0
0
Hi
I have written some basic code to move a set of images from one directory to another based on a list stored within an excel sheet

Code:

Sub MoveFiles()

    Dim SourcePath As String
    Dim DestPath As String
    Dim FileName As String
    Dim LastRow As Long
    Dim i As Long
   
    LastRow = Cells(Rows.Count, "A").End(xlUp).Row
   
    For i = 2 To LastRow
   
        FileName = Cells(i, "V").Value
   
        If Right(Cells(i, "W").Value, 1) <> Application.PathSeparator Then
            SourcePath = Cells(i, "W").Value & Application.PathSeparator
        Else
            SourcePath = Cells(i, "W").Value
        End If
       
        If Right(Cells(i, "X").Value, 1) <> Application.PathSeparator Then
            DestPath = Cells(i, "X").Value & Application.PathSeparator
        Else
            DestPath = Cells(i, "X").Value
        End If
       
        If Dir(SourcePath & FileName) = "" Then
            Cells(i, "D").Value = "Source file does not exist."
        ElseIf Dir(DestPath & FileName) <> "" Then
            Cells(i, "D").Value = "File already exists."
        Else
            Name SourcePath & FileName As DestPath & FileName
            Cells(i, "D").Value = "File moved to new location"
        End If
       
    Next i
       
End Sub

But due to restrictions on a particular auction site I now have to resize the images, and this is where I need your help. How would I use vba to resize the images as I move them from one directory to another, or even if I have to run a separate procedure afterwards don’t mind, but I just don’t know where to start

Thanks

Viewing all articles
Browse latest Browse all 13329

Trending Articles