office交流網--QQ交流群號

Access培訓群:792054000         Excel免費交流群群:686050929          Outlook交流群:221378704    

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

選中當前激活單元格裡的圖形(形狀)Shape

2020-06-06 08:00:00
zstmtony
原創
5090

使用以下代碼可以 選中當前激活單元格裡的圖形(形狀)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

分享