Previous  Home  Next

Is it safe to touch the text?

Not all shapes can have text. If you try to access a text property of one of these, PowerPoint errors out.
In addition, some shapes created by PowerPoint 97 can be corrupted to the point where, though they have the ability to hold text, they cause errors if you try to check for the text.

This is kind of a safety check function. It tests the various things that might cause errors and returns True if none of them actually cause errors.

Public Function IsSafeToTouchText(pShape As Shape) As Boolean

	On Error GoTo Errorhandler

	If pShape.HasTextFrame Then
		If pShape.TextFrame.HasText Then
			' Errors here if it's a bogus shape: 
			If Len(pShape.TextFrame.TextRange.text) > 0 Then
				' it's safe to touch it
				IsSafeToTouchText = True
				Exit Function
			End If ' Length > 0
		End If ' HasText
	End If ' HasTextFrame

Normal_Exit:
	IsSafeToTouchText = False
	Exit Function

Errorhandler:
	IsSafeToTouchText = False
	Exit Function

End Function
Previous  Home  Next