Knowledge base KB0073

How to find out with VBA if a shape is used by think-cell?

Every shape that is encountered by think-cell is marked with a tag. In addition to PowerPoint shapes, think-cell might also place a special shape (ActiveDocument container) on slides, slide masters, or custom layouts. This ActiveDocument container is not visible and contains special information about think-cell objects.
In the PowerPoint object model, each PowerPoint.Shape object has a Tags collection. think-cell sets the special tag thinkcellShapeDoNotDelete to help identify shapes. The value of the special tag is set to thinkcellActiveDocDoNotDelete for the ActiveDocument container, for all other think-cell controlled shapes it starts with t.

Example: How to check for think-cell shapes?

The following VBA function demonstrates how to classify a given PowerPoint.Shape object using the special tag:

Sub CheckShape(oShape As PowerPoint.Shape)
    Dim str As String
    str = oShape.Tags.Item(Name:="thinkcellShapeDoNotDelete")
    If (str = "" Or Left$(str, 1) <> "t") Then
        MsgBox "PowerPoint shape"
        If str = "thinkcellActiveDocDoNotDelete" Then
            MsgBox "think-cell ActiveDocument"
            MsgBox "think-cell shape"
        End If
    End If
End Sub

You can use this function to identify all shapes on the active slide:

Sub Test()
    Dim oShape As PowerPoint.Shape
    For Each oShape In ActiveWindow.View.Slide.Shapes
        Call CheckShape(oShape)
    Next oShape
End Sub

Please note that the tags collection of each shape is also copied whenever you copy a shape, e.g., by copying and pasting the think-cell chart. CheckShape will report think-cell shape for all shapes that have been part of a think-cell chart even if a shape has been copied and pasted into another presentation.

You may also be interested in reading KB0107: How can I copy-paste think-cell charts in my VBA Code?