简体   繁体   中英

Excel Vba Copy Picture to new sheet

i have below vba codes copy existing worksheet data to new worksheet, it's working fine, but it won't copy pictures file (eg.jpg) in worksheet, how can i copy picture file as well? Thank you.

  Set source2 = Worksheets("today").Range("A5:l68")

       Sheets.Add After:=Sheets(Sheets.Count)
    Set dest2 = ActiveWorkbook
    Source2.Copy
      With dest2.Sheets(2)
       .Cells(1).PasteSpecial Paste:=8
       .Cells(1).PasteSpecial Paste:=xlPasteValues
       .Cells(1).PasteSpecial Paste:=xlPasteFormats
       .Cells(1).Select

    Application.CutCopyMode = False

End With

I think this question is a duplicate of copy & paste a picture from one sheet to another , regardless you can use the code below...This should paste Pictures to new sht in approx same position as original sheet.

Sub MG15Jun43
Dim pic As Shape, rng As Range
For Each pic In ActiveSheet.Shapes
   If pic.Type = msoPicture Then
     pic.Copy
     With Sheets("Sheet2")
        .Select
        .Range(pic.TopLeftCell.Address).Select
        .Paste
     End With
     Selection.Placement = xlMoveAndSize
   End If
Next pic
End Sub

尝试使用:

Sheets("today").Copy After:=Sheets(Sheets.Count)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM