Results 1 to 2 of 2

Thread: Copying and Pasting Images/Objects to another workbook.
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Aug 2019
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Copying and Pasting Images/Objects to another workbook.

    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

  2. #2
    New Member
    Join Date
    Aug 2019
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Copying and Pasting Images/Objects to another workbook.

    I just got the answer from a co worker of mine. Will post the answer momentarily.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •