none
diff between Paragraph & table cell RRS feed

  • Question

  • when i pass through a document and want to getting necessary information about the text, tables, images and so on, i use these information just want to find anything changed other than history version.

    there is a question is, a table cell is exactly a paragraph,  so when i pass through the paragraphs, this also include all the table cells, has any way to check a paragraph whether is a table cell?

    i have an idea is to checking the paragraph's Range which is it in Table's Range, i use code bellow:

    Paragraphs lps = this.vstoDocument.Paragraphs;

    IEnumerator ie = lps.GetEnumerator(); while (ie.MoveNext()) { Paragraph p = (Paragraph)ie.Current; Style style = (Style)p.get_Style(); string temp = (p.Range.Text.Trim()); bool inRange = p.Range.InRange(t.Range); Debug.WriteLine(temp + " inRange:" + inRange); }

    this code can be work, but when a document has huge number tables, the algorithm will going to inefficient.

    is another way to solve this problem, help me,!

    Thursday, November 28, 2013 3:06 AM

Answers

  • You can test whether a range is in a table, via VBA code like:

    If .Range.Information(wdWithInTable) = True then
       'in a table
    Else
       'not in a table
    End If


    Cheers
    Paul Edstein
    [MS MVP - Word]


    • Edited by macropodMVP Thursday, November 28, 2013 3:54 AM
    • Marked as answer by sendreams Thursday, November 28, 2013 6:40 AM
    Thursday, November 28, 2013 3:54 AM

All replies

  • You can test whether a range is in a table, via VBA code like:

    If .Range.Information(wdWithInTable) = True then
       'in a table
    Else
       'not in a table
    End If


    Cheers
    Paul Edstein
    [MS MVP - Word]


    • Edited by macropodMVP Thursday, November 28, 2013 3:54 AM
    • Marked as answer by sendreams Thursday, November 28, 2013 6:40 AM
    Thursday, November 28, 2013 3:54 AM
  • it's ok. thank you very much.

    Thursday, November 28, 2013 6:39 AM