Hello Dave,
I have a quick test in my side, but the result is that I did not get the
table from the textRange.Parent. I stored the textRange by accessing the
Table.Cell(i,j).Shape.TextFrame.TextRange. So would you mind letting me
know how you get the textRange.
In my side, I can get the a textFrame from the textRange.Parent, and then
get a shape from the textFrame.Parent. Iterating through all of the cells
in the table, I can find one cell whose Shape property matchs the
textRange.Parent.Parent. The codes in my side looks like,
PowerPoint.TextRange textRange;
private void button2_Click(object sender, RibbonControlEventArgs e)
{
Random r = new Random();
//get a random textRange of a cell in the table and store it
textRange =
Globals.ThisAddIn.Application.ActivePresentation.Slides[1].Shapes[1].Table.C
ell(r.Next(1,5),r.Next(1,5)).Shape.TextFrame.TextRange;
}
private void button1_Click(object sender, RibbonControlEventArgs e)
{
//From the stored textRange, get the row and column index of
the cell
PowerPoint.TextFrame tFrame = textRange.Parent as
PowerPoint.TextFrame;
PowerPoint.Shape shape = tFrame.Parent as PowerPoint.Shape;
PowerPoint.Table table =
Globals.ThisAddIn.Application.ActivePresentation.Slides[1].Shapes[1].Table
as PowerPoint.Table;
for (int i = 1; i <= table.Rows.Count; i++)
{
for (int j = 1; j <= table.Columns.Count; j++ )
{
if (table.Cell(i, j).Shape == shape)
{
MessageBox.Show(i.ToString() + " " + j.ToString());
}
}
}
}
Please let me know if this addresses your issue. If you have any questions
or concerns on this, please let me know.
Have a nice day Dave!
Best regards,
Ji Zhou (
[email protected], remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
[email protected].
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.