KB0073: How do I use VBA to find out if a shape is used by thinkcell?
- Home
- Resources
- Knowledge base
- KB0073
Every shape that is encountered by thinkcell is marked with a tag. In addition to PowerPoint shapes, thinkcell 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 thinkcell objects. In the PowerPoint object model, each PowerPoint.Shape object has a Tags collection. thinkcell 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 thinkcell controlled shapes it starts with t.
Example: How to check for thinkcell 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"
Else
If str = "thinkcellActiveDocDoNotDelete" Then
MsgBox "thinkcell ActiveDocument"
Else
MsgBox "thinkcell 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 thinkcell chart. CheckShape will report thinkcell shape for all shapes that have been part of a thinkcell 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 thinkcell charts in my VBA Code?