VBA: Given a PPT textrange, what slide is it on?

D

Dave Jenkins

Here's a textrange: Tell me what slide it's on.

I'm hoping the solution to this is easy, but I can't seem to dope it out:
Given an arbitrary textrange, I need to know the slide number on which that
textrange exists. And that's regardless of whether the textrange is part of
grouped shape, non-grouped shape, table cell (both PPT 2003 and 2007), ...

Thanks.
 
C

Chirag

The third parent seems to always return the slide object for a TextRange:

Function GetSlideForTextRange(ByVal TxtRng As TextRange) As Slide
Set GetSlideForTextRange = TxtRng.Parent.Parent.Parent
End Function

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 
S

Shyam Pillai

Use the parent object to do a reverse qualifying lookup to get the slide.

This will get the name of the slide for the selected text range.

?Activewindow.Selection.TextRange.Parent.Parent.Parent.Name
Slide1

Regards,
Shyam Pillai

http://skp.mvps.org
 

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