Odd selections within table cell. RRS feed

  • Question

  • Hi,

    I have a very simple table with two rows and two columns. In the first cell I have the text "Hello," and "World" separated by a hard carriage return.

    When I process this text I loop through all the paragraphs within the cell range with code such as:

    foreach (Paragraph p in cell.Range.Paragraphs) 

    Within the loop I select the paragraph range and pull out the text for the range AND the selection.


        String s1 = p.Range.Text

        String s2 = Globals.ThisAddIn.Application.Selection.Text

    For the first paragraph - first time through the loop - all is fine. Strings s1 and s2 both contain the text "Hello,\r". The second time around the loop it goes wrong, s1 contains the text "World\r\a" which is what I would expect but s2 contains the text "Hello,\rWorld\r\a" which is not what I would expect. The Select() seems to have selected more than the range it was based on?

    Any help or advice on why this is happening would be appreciated.

    Many thanks


    Thursday, February 21, 2019 3:21 PM