0
votes

I am trying to create a new PowerPoint plug-in. I have run into a problem for a case where I want to determine if for a given shape on slide 1, whether the same shape also exists on the next slide.

Is there a way by which I can compare shapes from different slides and determine whether they are the same?

I can probably compare the type, dimensions, text and other similar properties, but this may not be the right way to solve this problem. Is there a better way to do this?

2

2 Answers

0
votes

What is an "identical" Shape for you? All shapes hafe different IDs so you cannot compare them, but you could compare the Size, the location (Shape.Width, Shape.Height etc.) and maybe the content (a chart, a table or text?). If enough Properties are equal they might be considered as equal.

0
votes

Something like this will return an "identical" shape from another slide if it meets your criteria. You could have it return True/False instead if you prefer:

Function SameShape(oThisShape As Shape, oOtherSlide As Slide) As Shape

    Dim oSh As Shape

    For Each oSh In oOtherSlide.Shapes
        If oSh.Type = oThisShape.Type Then
            If oSh.Height = oThisShape.Height Then
                If oSh.Width = oThisShape.Width Then
                    ' other conditions here as required
                    Set SameShape = oSh
                    Exit Function
                End If
            End If
        End If
    Next

End Function

One caveat: if the shape's .Type = msoPlaceholder, you'll also need to look to see whether .PlaceholderFormat.ContainedType is the same.