PowerPoint tables and vba

G

Guest

Having a problem with this.

We need to check which cell the cursor is in in a PPT table using vba. I
know how to iterate through the table and I figured
.cell(Irow,Icol).selected
would tell me but it' s coming up false in all cells (even if I actually
select the text)
Using 2003 SP2

Any ideas (Shyam I'm looking at you! - I've seen the relevant page on your
site but that comes up no cells selected too)
 
S

Shyam Pillai

John,
The code snippet I have on my site works for cells which are selected and
not for the cells which have text selected in them. The Selected property is
True only when the entire cell is selected.

You can always get a reference back to the cell containing the text using
the Parent property. Assuming that you've written the code to check if it is
a table shape, you can retrieve the shape which holds the cursor/text
selection as follows:

Dim oShp As Shape
Set oShp = ActiveWindow.Selection.TextRange.Parent.Parent

Read as: ActiveWindow.Selection.TextRange.Parent(TextFrame).Parent(Shape)

This shape reference is to the rectangle contained within the table, you can
now manipulate the same as a regular shape.

Note that this does not work in PPT 2007. The OM is broken.


--
Regards,
Shyam Pillai

Image Importer Wizard
http://skp.mvps.org/iiw.htm
 
G

Guest

Thanks Shyam. I'm off to try that. It's for an XP user so it should be OK.
--
Amazing PPT Hints, Tips and Tutorials-http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk


Shyam Pillai said:
John,
The code snippet I have on my site works for cells which are selected and
not for the cells which have text selected in them. The Selected property is
True only when the entire cell is selected.

You can always get a reference back to the cell containing the text using
the Parent property. Assuming that you've written the code to check if it is
a table shape, you can retrieve the shape which holds the cursor/text
selection as follows:

Dim oShp As Shape
Set oShp = ActiveWindow.Selection.TextRange.Parent.Parent

Read as: ActiveWindow.Selection.TextRange.Parent(TextFrame).Parent(Shape)

This shape reference is to the rectangle contained within the table, you can
now manipulate the same as a regular shape.

Note that this does not work in PPT 2007. The OM is broken.


--
Regards,
Shyam Pillai

Image Importer Wizard
http://skp.mvps.org/iiw.htm
 
G

Guest

Thanks that has helped a lot!
--
Amazing PPT Hints, Tips and Tutorials-http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk


Shyam Pillai said:
John,
The code snippet I have on my site works for cells which are selected and
not for the cells which have text selected in them. The Selected property is
True only when the entire cell is selected.

You can always get a reference back to the cell containing the text using
the Parent property. Assuming that you've written the code to check if it is
a table shape, you can retrieve the shape which holds the cursor/text
selection as follows:

Dim oShp As Shape
Set oShp = ActiveWindow.Selection.TextRange.Parent.Parent

Read as: ActiveWindow.Selection.TextRange.Parent(TextFrame).Parent(Shape)

This shape reference is to the rectangle contained within the table, you can
now manipulate the same as a regular shape.

Note that this does not work in PPT 2007. The OM is broken.


--
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