开发者

Is it possible to get selected cells in Microsoft.Office.Interop.PowerPoint.Table?

I've a table in powerpoint document (table type: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerp开发者_如何学运维oint.table.aspx)

What i want to achive is to get a collection of cells selected by user. if myPres.Application.ActiveWindow.Selection.ShapeRange.Type == Microsoft.Office.Core.MsoShapeType.msoTable

Then i can get selected table via: myPres.Application.ActiveWindow.Selection.ShapeRange.Table property but i can't see if there is any information regarding selected cells.

UPDATE:

As @SteveRindsberg pointed out below i should mention which office version i'm using. It's Office 2007 in my case. Shortest answer (again thanks to @SteveRindsberg) to my question is: every cell has Selected boolean property


It's always a good idea to mention which version of PowerPoint you're working with, as some things (tables among them) have changed in major ways from one version to the next.

Here are a couple hints that might help:

If the user has selected several cells, ActiveWindow.Selection.Type will = ppSelectionShapes To work out which cells are selected, iterate through all the cells in the table and test each one's .Selected property.

If the user has selected text within a cell or just clicked within a cell, ActiveWindow.Selection.Type will = ppSelectionText

ActiveWindow.Selection.TextRange.Text gives you the selected text but in PPT 2007 and on, the OM is broken. You should be able to walk up the .Parent chain from there to get to the parent cell or shape, but you can't. However you can still iterate through the cells and look for the one where .Selected = True.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜