Thank-you. It's weird but after I changed the code to this:
Function Shapes_Exist(WS As Worksheet, ShapeName As String, ByRef SetShape As Shape) As Boolean
' does the shape with the ShapeName name exist?
Dim tmpID As Long
On Error GoTo ShapeNotExist
Shapes_Exist = False
tmpID = WS.Shapes(ShapeName).Id
If IsEmpty(tmpID) Then
Shapes_Exist = False
Else
Shapes_Exist = True
Set SetShape = WS.Shapes(ShapeName)
End If
ShapeNotExist:
On Error GoTo 0
End Function
it now works as intended.
I use the function extensively to check if shapes exist, and create or destroy them depending on whether they should exist. It's all working as intended. I am now puzzled - why does this new code work? Thanks!
Bookmarks