PowerPoint question

J

Joseph M. Newcomer

I have an automation interface to PowerPoint. Currently, I get a slide, so I have a
CSlide object (I'm programming in MFC). I want to get the slide title. I've tried
various forms of get_Title, but the poorly-documented (or, shall we call a spade and spade
and say what's really true, "undocumented') structure is nearly inpenetrable.

I need to ask if it has a title, and if it has a title, if the title has text, and if the
title has text, I want to get the text string. All of this in MFC. I've now spent too
much time on this, and I need to get on with the rest of the project. So I'd appreciate
some pointers on what the structure is,

I also discovered that if I copy slides from one presentation into another, it gets really
confused about the placeholders. It thinks I have 1 placeholder, whereas in the original
(or, if I add a new slide, and copy the title from the copied slide into the new slide,
and the text from the copied slide into the new slide) then it sees the placeholders again
and I get a count of 2 placeholders. This sounds like a serious bug in how copy is
implemented.

I'm using the last usable version of PowerPoint, PowerPoint 2003.
joe
Joseph M. Newcomer [MVP]
email: (e-mail address removed)
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
 
S

Steve Rindsberg

I have an automation interface to PowerPoint. Currently, I get a slide, so I have a
CSlide object (I'm programming in MFC). I want to get the slide title. I've tried
various forms of get_Title, but the poorly-documented (or, shall we call a spade and spade
and say what's really true, "undocumented') structure is nearly inpenetrable.

I need to ask if it has a title, and if it has a title, if the title has text, and if the
title has text, I want to get the text string. All of this in MFC.

Can't help with MVC but ...

Sub StituteMFCForThis()

Dim oSl As Slide
Dim oSh As Shape

Set oSl = ActivePresentation.Slides(1)

For Each oSh In oSl.Shapes
With oSh
If .Type = msoPlaceholder Then ' VB long = 14
If .PlaceholderFormat.Type = ppPlaceholderTitle Then
' ppPlaceholderTitle = 1
' test also for ppPlaceholderCenterTitle, 3
If .HasTextFrame Then
If .TextFrame.HasText Then
MsgBox .Text
End If
End If
End If
End If
End With
Next

End Sub

Ie, iterate through the shapes collection of the slide.
If a shape is a placeholder type then check to see whether its PlaceholderFormat.Type says it's a
title.
If so, verify that it has a text frame and that the text frame has text.
If so, do what you need to with the .Text
I also discovered that if I copy slides from one presentation into another, it gets really
confused about the placeholders. It thinks I have 1 placeholder, whereas in the original
(or, if I add a new slide, and copy the title from the copied slide into the new slide,
and the text from the copied slide into the new slide) then it sees the placeholders again
and I get a count of 2 placeholders. This sounds like a serious bug in how copy is
implemented.

Can you post an example of the before and after along with steps to repro manually?
 
J

Joseph M. Newcomer

Thanks. The translation from VBA to MFC is trivial for me, so this was what I needed.
I'll try it sometime this afternoon.
joe

Can't help with MVC but ...

Sub StituteMFCForThis()

Dim oSl As Slide
Dim oSh As Shape

Set oSl = ActivePresentation.Slides(1)

For Each oSh In oSl.Shapes
With oSh
If .Type = msoPlaceholder Then ' VB long = 14
If .PlaceholderFormat.Type = ppPlaceholderTitle Then
' ppPlaceholderTitle = 1
' test also for ppPlaceholderCenterTitle, 3
If .HasTextFrame Then
If .TextFrame.HasText Then
MsgBox .Text
End If
End If
End If
End If
End With
Next

End Sub

Ie, iterate through the shapes collection of the slide.
If a shape is a placeholder type then check to see whether its PlaceholderFormat.Type says it's a
title.
If so, verify that it has a text frame and that the text frame has text.
If so, do what you need to with the .Text


Can you post an example of the before and after along with steps to repro manually?
Joseph M. Newcomer [MVP]
email: (e-mail address removed)
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
 
S

Steve Rindsberg

Thanks. The translation from VBA to MFC is trivial for me, so this was what I needed.

You're welcome, and from past conversations, I didn't expect that the VBA would be an issue.
 
J

Joseph M. Newcomer

Hmmm...I fixed a couple bugs (it should be
If oSh.HasTextFrame Then
If oSh.TextFrame.HasText Then
If MsgBox(Str(oSl.SlideNumber) + ": " +
oSh.TextFrame.TextRange.Text, vbOKCancel) = vbCancel Then
Exit Sub
End If
End If
End If

(I tried the VBA first...)

but the problem now is that when I ask in MFC
if(textframe.get_HasText())
then it always returns FALSE. Weird. I'm exploring that next, but everything else seems
to work correctly.
joe

You're welcome, and from past conversations, I didn't expect that the VBA would be an issue.
Joseph M. Newcomer [MVP]
email: (e-mail address removed)
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
 
J

Joseph M. Newcomer

Found the problem. I was using the wrong 'shapes' that was passed into my function (I was
using the shapes of the notes page, not the shapes of the slides!)

I expect to put the new indexer up sometime next week. Thanks.

joe
Hmmm...I fixed a couple bugs (it should be
If oSh.HasTextFrame Then
If oSh.TextFrame.HasText Then
If MsgBox(Str(oSl.SlideNumber) + ": " +
oSh.TextFrame.TextRange.Text, vbOKCancel) = vbCancel Then
Exit Sub
End If
End If
End If

(I tried the VBA first...)

but the problem now is that when I ask in MFC
if(textframe.get_HasText())
then it always returns FALSE. Weird. I'm exploring that next, but everything else seems
to work correctly.
joe


Joseph M. Newcomer [MVP]
email: (e-mail address removed)
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: (e-mail address removed)
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top