How to get selected text from a table cell in PPT 2007 using VBA?

D

Dave

I seem to be unable to get my hands on the textrange for selected text
contained within a table cell in PPT 2007. I did have some code that
worked in PPT 2003 (definitions, etc. removed for brevity):

' anything selected that contains text?
With ActiveWindow.Selection

' has more than one shape been selected?
If .Type = ppSelectionText Then
If .TextRange <> "" Then <== error on this line
Set temp = .TextRange
tRanges.Add temp
Else
For i = 1 To ActiveWindow.Selection.ShapeRange.Count
BuildTextRangeCollection
ActiveWindow.Selection.ShapeRange(i), tRanges
Next i
End If
..
..
..

When I run this code in 2007 with a portion of the text in one table
cell selected, I get a "Specified value is out of range" VBA error on
the specified line.

If I run the code with a complete cell or cells selected, I don't get
the error, but the routine at BuildTextRangeCollection is unable to
identify any textranges associated with the selected shapes.

Is there a workaround for this? Thanks ...
 
B

Bill Dilworth

I think the problem may be that you are comparing a 'text range' object to a
'text string' object. Try adding .text after the .textrange so that you are
comparing two 'text strings'.

--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
vestprog2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
D

Dave

The comparison of a textrange object to a string has worked all along
(in 2003, i.e.), and continues to work in 2007, provided the textrange
exists. Nevertheless, I made the change you suggested but the problem
persists.

The problem here is that the properties of the selection, whether it
be a portion of the text in a cell, or the entire cell, show in the
debugger the following value for the selection's textrange:
"<Specified value is out of range>."

Got any other insights, BIll? Thanks!
 
D

Dave Jenkins

Not sure I understand, Steve. Are you suggesting that I just comment out the
code that gives me the range(s) that the user has selected? That kind of
flies in the face of what I'm trying to accomplish, doesn't it?
 
S

Shyam Pillai

The table in PowerPoint 2007 is a different animal altogether and though
automation works in parts, it does not work for what you are attempting. So
you are out of luck in this case.


--
Regards,
Shyam Pillai

Image Importer Wizard
http://skp.mvps.org/iiw.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