Excel Vba将图片复制到新表 [英] Excel Vba Copy Picture to new sheet

查看:1388
本文介绍了Excel Vba将图片复制到新表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面的vba代码中将现有的工作表数据复制到新的工作表中,效果很好,但不会在工作表中复制图片文件(例如jpg),我该如何复制图片文件?谢谢.

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

这篇关于Excel Vba将图片复制到新表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆