Determining if defaultshape contains default text

  • Thread starter Thread starter Alex Bendig
  • Start date Start date
A

Alex Bendig

Hi all,

How can I determine if a shape shp that is a defaultShape contains actual
text or just the default text ("Click to add title", etc.)? For both all
conditions below appear to be true.

if (shp.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
{
if (shp.TextFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
{
if (shp.Type == Microsoft.Office.Core.MsoShapeType.msoPlaceholder)
{

}
}
}

Maybe the handling of default text is something that PowerPoint does
internally without exposing the information at all, though I certainly hope,
someone is able to prove the opposite ;-)

Thanks and regards,
Alex
 
Alex,
HasText property will return a False for an empty placeholder with the
default text "Click here to ...". It will return a True if user has entered
some text within. Are you seeing otherwise?

Regards
Shyam
 
If Shp.HasTextFrame Then
If Shp.TextFrame.HasText Then
MsgBox Shp.TextFrame.TextRange.Text
End If
End If

Here (PPT2000) the msgbox never executes if it's a Click Here text box that
nobody's Clicked Here on, so to speak.

I think there was a bug in an earlier version of PPT that caused examining
the text box in VB to plug in a null or the like, making PPT think that
there WAS text there. Any chance you're seeing something like that?

--

Steve Rindsberg PPT MVP
PPTLive ( http://www.pptlive.com ) Featured Speaker
PPTools: http://www.pptools.com
PPT FAQ: http://www.pptfaq.com
 
Shyam,

Yes, unfortunately I do. I double-checked to make sure I don't accidently
access
TextFrame.TextRange.Text directly or store text before trying to retrieve
it, but I am now quite certain that this is the first spot where I actually
access the text of any given shape.

public string getText(PowerPoint.Shape shp)
{
if (shp.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
{
if (shp.TextFrame.HasText ==
Microsoft.Office.Core.MsoTriState.msoTrue)
{
return shp.TextFrame.TextRange.Text; // [*]
}
else
{
return null;
}
}
else
{
return null;
}
}

The line marked with [*] always appears to get executed for placeholder
shapes that contain text - no matter if this is the default text ("Click to
add ..." etc.) or actual user-entered text.

Any input would be appreciated.

Regards,
Alex
 
Back
Top