think-cell 遇到的每个形状都由某标记进行标记。除了 PowerPoint 形状之外,
think-cell 可能还会将特殊形状(ActiveDocument 容器)放置在幻灯片、幻灯片母版或自定义布局上。该 ActiveDocument 容器不可见,并包含有关 think-cell 对象的特殊信息。
在 PowerPoint 对象模型中,每个 PowerPoint.Shape 对象都具有 Tags 集合。think-cell 会设置特殊标记 thinkcellShapeDoNotDelete 以协助识别形状。对于 ActiveDocument 容器,该特殊标记的值将设为 thinkcellActiveDocDoNotDelete,对于 think-cell 控制的所有其他形状,该值会以 t 开头。
示例:如何检查是否存在 think-cell 形状?以下 VBA 函数将展示如何使用特殊标记对指定的 PowerPoint.Shape 对象进行归类:
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 "think-cell ActiveDocument"
Else
MsgBox "think-cell shape"
End If
End If
End Sub
您可以使用此函数来识别活动幻灯片上的所有形状:
Sub Test()
Dim oShape As PowerPoint.Shape
For Each oShape In ActiveWindow.View.Slide.Shapes
Call CheckShape(oShape)
Next oShape
End Sub
请注意在您复制形状(例如,通过复制并粘贴 think-cell 图表的方式)时,也会复制每个形状的标记集合。CheckShape 会报告 think-cell shape,以指出已包含在 think-cell 图表中的所有形状,即使已将形状复制并粘贴到其他演示文稿中,也是如此。