Hello! There is a code that searches for text in Word'e and returns the Range object accordingly (I can iterate over paragraphs and output), but how can I proceed? If I want to post the following lines after this text, but I am given the opportunity to control only one paragraph, and how can I move to the next after it? Or how to 'highlight the desired range' from the found Range - to reach the end, SetRange requires positions, how to get them?
private Word.Range FindInWord() { object stringToFindObj = textBox1.Text; Word.Range wordRange; bool rangeFound; object _missingObj = Type.Missing; for (int i = 1; i <= doc.Sections.Count; i++) { wordRange = doc.Sections[i].Range; Word.Find wordFindObj = wordRange.Find; object[] wordFindParameters = { stringToFindObj, _missingObj, _missingObj, _missingObj, _missingObj, _missingObj, _missingObj, _missingObj, _missingObj, _missingObj, _missingObj, _missingObj, _missingObj, _missingObj, _missingObj }; rangeFound = (bool)wordFindObj.GetType().InvokeMember("Execute", BindingFlags.InvokeMethod, null, wordFindObj, wordFindParameters); if (rangeFound) { return wordRange; } } return null; }