Код: Выделить всё
#region FindRanges
/*
* Erstellt eine Liste aus Ranges wo überall das gesuchte pattern vorhanden ist.
* Der Bereich der Range ist immer von Parent bis nach dem gesuchten pattern.
*/
public virtual List FindRanges(Range searchRange, String pattern, Boolean wildcards)
{
List ranges = new List();
Word.Document document;
Range rng;
try
{
document = searchRange.Parent;
var find = searchRange.Find;
find.Text = pattern;
find.MatchWildcards = wildcards;
find.Execute();
while (find.Found)
{
rng = document.Range(searchRange.Start, searchRange.End);
ranges.Add(rng);
find.Execute();
}
}
catch (Exception e)
{
log.Error(e);
}
return ranges;
}
#endregion FindRanges
метод вызывается отсюда:
Код: Выделить всё
var pattern = "(" + id + ")(_[0-9]@)>";
var ranges = FindRanges(Document.Content, pattern, true);
Код: Выделить всё
System.Runtime.InteropServices.COMException (0x800A16C9): Beim Speichern der "Rückgängig"-Information ist ein Fehler aufgetreten.
bei Microsoft.Office.Interop.Word.Find.Execute(Object& FindText, Object& MatchCase, Object& MatchWholeWord, Object& MatchWildcards, Object& MatchSoundsLike, Object& MatchAllWordForms, Object& Forward, Object& Wrap, Object& Format, Object& ReplaceWith, Object& Replace, Object& MatchKashida, Object& MatchDiacritics, Object& MatchAlefHamza, Object& MatchControl)
//(Translated into English, this roughly means: An error occurred while saving the "undo" information.)
Заранее спасибо, буду очень признателен за помощь!>
Подробнее здесь: https://stackoverflow.com/questions/787 ... mexception