Problems with Textholders


I have been working with modifying text in various placeholders:

Dim th As TextHolder = pholders(0)

I find that this works fine when I am using a placeholder type of 'CenteredTitle2', which is the main placeholder on a title slide, but not when I am using a 'Subtitle' placeholder.

I get this: System.InvalidCastException: Specified cast is not valid.

Can you help me out and explain why this happens?



Slide.Placeholders collection contains Placeholder and TextHolder objects.
Placeholder can’t be casted to the TextHolder type.



I am following code on your WIKI:

Dim pholders As Placeholders = GetSlideByPosition(pres, 1).Placeholders
Dim th As TextHolder = pholders(0)
If th.Text = "PH1" Then
th.Paragraphs(0).Portions(0).Text = "Hello World "
End If

How else (please, with actual code example) can I modify the text within the 2 placeholders on a title slide?

I have tried this also:

Dim oShape2 As Slides.Shape
oShape2 = _pptdoc.Slides(0).Shapes(0)
oShape2.TextFrame.Text = "Testing"

This does not produce an error, but also does not change the text on the slide when viewed.

Thanks for your help, Tom