PowerPoint 2007 - Get reference to selected placeholder

P

Pete

Hi,

In PowerPoint 2007, how do you get a reference to the selected placeholder
object when the user clicks inside? If ActiveWindow.Selection.Type gives you
a value of ppSelectionText then you don't seem to be able to get a reference
to the ShapeRange property of the Selection object. I tried

ActiveWindow.Selection.ShapeRange.Item(1)

to get the placeholder shape but this just gave me an error: "Invalid
Request. Nothing appropriate is currently selected".

Any ideas?

Pete
 
S

Steve Rindsberg

Hi,

In PowerPoint 2007, how do you get a reference to the selected placeholder
object when the user clicks inside? If ActiveWindow.Selection.Type gives you
a value of ppSelectionText then you don't seem to be able to get a reference
to the ShapeRange property of the Selection object.

Walk the .Parent tree from the selection object:

Sub WhoIsYourDaddy()
With ActiveWindow.Selection
If .Type = ppSelectionText Then
With ActiveWindow.Selection.TextRange
Debug.Print TypeName(.Parent) ' TextFrame
Debug.Print TypeName(.Parent.Parent) ' Shape
Debug.Print TypeName(.Parent.Parent.Parent) ' Slide
End With
End If
End With
End Sub



I tried
 
P

Pete

Hi Steve,

I'd expect that to work but I get the same error from:

TypeName (ActiveWindow.Selection.TextRange.Parent)

which is:

"Selection (unknown member): Invalid request. Nothing appropriate is
currently selected."

I'm wondering if this is a VSTO 2 issue. I might try creating a VBA project
and seeing if I get the same thing. Then I'll try VSTO 3. I'll let you know

Thanks anyway,

Pete
 
S

Steve Rindsberg

Hi Steve,

I'd expect that to work but I get the same error from:

TypeName (ActiveWindow.Selection.TextRange.Parent)

which is:

"Selection (unknown member): Invalid request. Nothing appropriate is
currently selected."

Is the text cursor within a table cell?

Tables are all but hopelessly broken in 2007 and IIRC, this is one of the symptoms.
 

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