Copy all images from an excel file

Dear,

I need some help, I need to copy all the images that are inside the sheet of the attached spreadsheet and insert it into another spreadsheet, there are several ways, I even found an activity in balareva that performs this type of task, someone has already managed to perform this type of automation?

print.xlsx (209.9 KB)

Hi @Israel_Silva you can use VBA for this. i have a similar solution with me i can share it you personally if you want.

2 Likes

Thanks for the answer @Mohammad_Irfan , I’m sure it’s of interest, if possible could you share
?

@Israel_Silva

Please try using this vba

Sub CopyImages(OutWbk As String,OutSheet As String)
    Dim img As Shape
    Dim SourceWorkbook As Workbook
    Dim DestinationWorkbook As Workbook
    Dim SourceSheet As Worksheet
    Dim DestinationSheet As Worksheet
    Dim i As Integer
    
    Set SourceWorkbook = ActiveWorkbook
    Set DestinationWorkbook = Workbooks.Open(OutWbk)
    Set DestinationSheet = DestinationWorkbook.Worksheets(OutSheet)
    
    ' Loop through each sheet in the source workbook
    For Each SourceSheet In SourceWorkbook.Worksheets
        ' Loop through each image on the sheet
        For Each img In SourceSheet.Shapes
            ' Check if the shape is image
            If img.Type = msoPicture Then
                img.Copy
                DestinationSheet.Paste Destination:=DestinationSheet.Range("A1").Offset(i, 0)
                i = i + 1
            End If
        Next img
    Next SourceSheet
    DestinationWorkbook.SaveAs
    DestinationWorkbook.Close
End Sub

Use excel file wirh source excel and use invoke vba inside that use excel scope…and save this vba in a text file and gice the details

Hope this helps

Cheers