views:

323

answers:

1

How do you search for a specific text inside a text run (in Docx using the OpenXML SDK 2.0) and once you find it how do you insert a comment surrounding the 'search text'. The 'search text' can be a sub string of an existing run. All example in the samples insert comments around the first paragraph or something simple like that... not what I'm looking for.

Thanks

A: 

You have to break it up into separate runs. Try using the DocumentReflector - it even genereates C# code - to look at a document created with word. The structure should look something like this (simplified):

<paragraph>
  <run>...</run>
  <commentRangeStart />
  <run>search text</run>
  <commentRangeEnd />
  <run>...</run>
</paragraph>
kern