Copy image from one workbook to another workbook

后端 未结 1 1534
遥遥无期
遥遥无期 2021-01-22 01:33

I have an image in a sheet1 in a merged cell range S1:V8.

I don\'t know the name of this picture because we paste different pictures in the area each time we create a ne

相关标签:
1条回答
  • 2021-01-22 02:13

    It's not clear whether the picture you are referring to is "in the cell" or floating above the cells. As far as I know, the only way to have a picture "in a cell" is to have it within the comment of the cell (actually, intended as a background picture for comment text). In either case, the key to manipulating it using VBA would be to get a reference for it. The following code will identify the presence of either of the above cases if you first select the region of cells, as shown in the animated gif. Unfortunately, as far as I know, all you can do is add background pictures to comments via VBA.

    Option Explicit
    Sub testForPicturesOrComments()
    Dim p As Picture, r As Range, hasComment As Boolean
    For Each p In ActiveSheet.Pictures
      MsgBox ("There's a picture called " & p.Name)
    Next p
    For Each r In Selection
      On Error Resume Next
      hasComment = r.Comment.Parent.Address = r.Address
      'Reset Run Time Errors
      On Error GoTo 0
      If hasComment Then
      MsgBox ("There's a comment in " & r.Address _
      & " with a shape.ID = " & r.Comment.Shape.ID)
        hasComment = False
      End If
    Next r
    End Sub
    
    0 讨论(0)
提交回复
热议问题