Copying and Pasting Images/Objects to another workbook.

Varrius

New Member
Joined
Aug 16, 2019
Messages
2
Hi All,

I have been lurking around for an answer but haven't been able to find one for my issue. I am making a macro in Excel that will compile files into a larger file. These files to be compiled also have images in specific boxes that I haven't been able to get to come over. I would select all objects but I need every object Except the first one in each sheet i'm pasting from. I'm kind of new at using VBA and would appreciate any and all help. Here's my code:

Code:
Private Sub btnStitchData_Click()
Dim dsh As Worksheet
Dim sh As Worksheet
Dim wb As Workbook
Dim I As Integer
Dim n As Long


Dim blnCountingInit As Boolean
Dim blnShapeC As Boolean

Dim fso As New FileSystemObject
Dim fo As Folder
Dim x As File


Application.DisplayAlerts = False

Set fo = fso.GetFolder("C:\Users\PCCSa\Documents\PCC\Workbooks\Compiler")
Set dsh = ThisWorkbook.Sheets("Compile Test")

For Each x In fo.Files
    Set wb = Workbooks.Open(x.Path)
    Set sh = wb.Sheets("Invoice")
    
    
    If blnCountingInit = False Then
        n = dsh.Range("A" & Application.Rows.Count).End(xlUp).Row
        sh.UsedRange.Copy
        dsh.Range("A" & n).PasteSpecial xlPasteAllExceptBorders
        blnCountingInit = True
        
'This part is giving me the most issues. Stuck here because of runtime error 1004
        If blnShapeC = False Then
            sh.Shapes.Range(Array("Picture 2", sh.Shapes.Count)).Select
            Selection.Copy
            dsh.Range("Z16" & n).PasteSpecial xlPasteAllMergingConditionalFormats
        End If
    
    Else
        sh.Range("A15").Select
        sh.Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
        sh.UsedRange.Copy
        dsh.Range("A" & n + 1).PasteSpecial xlPasteAllExceptBorders
    End If
    
    wb.Close False

Next

End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top