office交流网--QQ交流群号

Access培训群:792054000         Excel免费交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

选中当前激活单元格里的图形(形状)Shape

2020-06-06 08:00:00
zstmtony
原创
178

使用以下代码可以 选中当前激活单元格里的图形(形状)Shape


Sub SelectPictureAtActiveCell()
  Dim Pic As Shape
  For Each Pic In ActiveSheet.Shapes
    If Pic.TopLeftCell.Address = ActiveCell.Address Then
      If Pic.Type = msoPicture Then
        Pic.Select
        Exit For
      End If
    End If
  Next
End Sub


其它可参考代码

Sub SelectPic()
Dim Pic As Picture
For Each Pic In ActiveSheet.Pictures
       If Pic.Name = "Picture 1" Then
              Pic.Left = ActiveCell.Left
              Pic.Top = ActiveCell.Top
       End If
       If Pic.Left = ActiveCell.Left And Pic.Top = ActiveCell.Top Then
              Pic.Select
              MsgBox Pic.Name
       End If
Next Pic
End Sub

分享