Referencing selected table cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I'm working with the Powerpoint object model for an Office add-in using .Net
2003. I can't figure out how to get a reference to a selected table cell. I
can get a reference to the table containing that cell using the Selection
object (...ShapeRange.Item(1)) or a specified cell in that table using the
Cell method e.g. Cell(1,1) etc but can someone tell me how to get a reference
to the cell that the user has clicked in? I'll probably want to do this on
the WindowSelectionChange event.
Thanks.
Pete
 
Had a similar problem a few weeks back (not in .net though) Shyam helped me
out with this suggestion to reference the shape clicked in within a table
(which is really only a collection of shapes)

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

Hpe that helps (did for me)
 
Hi John,

Thanks for the reply. I did apply that exact same workaround earlier today
which gives me 90% of what I need. Unfortunately you can't use
....TextRange.Parent.Parent.Parent to get the cell (or anything that you can
convert into a cell) which would have been ideal. I actually wanted to get
access to the Borders property of the cell so I could copy the formatting but
this is a "nice to have" feature and I think I can live with just accessing
the shape object. Thanks anyway.

Pete
 
Hi John,

Thanks for the reply. I did apply that exact same workaround earlier today
which gives me 90% of what I need. Unfortunately you can't use
....TextRange.Parent.Parent.Parent to get the cell (or anything that you can
convert into a cell) which would have been ideal. I actually wanted to get
access to the Borders property of the cell so I could copy the formatting but
this is a "nice to have" feature and I think I can live with just accessing
the shape object. Thanks anyway.

I've just added a few examples here:

Working with PowerPoint tables
http://www.pptfaq.com/FAQ00790.htm

The last set will let you do what you want, I think.

Basically the idea is:

TextRange.Parent.Parent --> the Shape that represents the current cell

Next you iterate through all the cells in the currently selected shape (the table
itself) and for each cell, test to see whether its .Shape.Name property matches
TextRange.Parent.Parent.Name

When it does, you've got the cell you're after.

Kinda the long way around the block but it gets you there.
 
Hi Steve,

I like it. I'll give that a go (after Easter). Thanks very much.

Say it with chocolate! <g>

Nah... my pleasure. I'd been meaning to get around to posting some more examples
anyway.
 
Back
Top