Sub test_CheckShapes()
MsgBox CheckShapes("picture 1")
'MsgBox CheckShapes("picture 1", AlertCount:=True)
Dim sh As Worksheet, reL&, reT&, reW&, reH&
Call CheckShapes("picture 1", , reL&, reT&, reW&, reH&, AlertCount:=True)
MsgBox "Left: " & reL & vbNewLine & _
"Top: " & reT & vbNewLine & _
"Width: " & reW & vbNewLine & _
"Height: " & reH
End Sub
Function CheckShapes(ByVal ShpName$, Optional WS As Worksheet, _
Optional ByRef reL&, Optional ByRef reT&, Optional ByRef reW&, Optional ByRef reH&, _
Optional ByRef AlertCount As Boolean = False) As Boolean
Dim shape, IsPicture As Boolean, k&, AllShape$
If WS Is Nothing Then Set WS = ActiveSheet
For Each shape In WS.Shapes
If LCase$(shape.Name) = LCase$(ShpName) Then
reL = shape.Left: reT = shape.Top
reW = shape.Width: reH = shape.Height
CheckShapes = True
End If
k = k + 1
AllShape = vbNewLine & AllShape & shape.Name
Next shape
If k > 0 And AlertCount Then MsgBox "Có " & k & " Shape trong Trang tính : " & WS.Name & AllShape
End Function