В функции
Код:
public void FindString()
{
Object missing = System.Reflection.Missing.Value;
Object confConv = false;
Object readOnly = true;
Object isVisible = false;
Object saveChanges = false;
Word.Application word = new Word.Application();
word.Visible = false;
Word.Document doc = null;
Word.Range docRange;
Object MatchCase = false;
Object MatchWholeWord = false; // !!! может быть ошибка, если true
Object MatchWildcards = false;
Object MatchSoundsLike = false;
Object MatchAllWordForms = false;
Object Forward = true;
Object Wrap = false;
Object Format = true;
Object ReplaceWith = false;
Object Replace = false;
Object MatchKashida = false;
Object MatchDiacritics = false;
Object MatchAlefHamza = false;
Object MatchControl = false;
string strFileOldFull = "";
foreach (string strFile in strDocFileName)
{
Object filename = strFile;
try
{
doc = word.Documents.Open(ref filename, ref confConv, ref readOnly);
}
catch (Exception)
{
strMes = "\nНе удается открыть файл --- " + strFile + " ---\n";
Console.WriteLine(strMes);
ioWriterFind.WriteLine(strMes);
((Word._Document)doc).Close(ref saveChanges, missing, missing);
continue;
}
Console.WriteLine('\n' + strFile + '\n');
foreach (string strFindFull in strArrFind)
{
Object FindText = strFindFull;
for(int nSec = 1; nSec <= doc.Sections.Count; nSec++)
{
docRange = doc.Sections[nSec].Range;
while(docRange.Find.Execute(ref FindText, ref MatchCase, ref MatchWholeWord, ref MatchWildcards,
ref MatchSoundsLike, ref MatchAllWordForms, ref Forward, ref Wrap,
ref Format, ref ReplaceWith, ref Replace, ref MatchKashida,
ref MatchDiacritics, ref MatchAlefHamza, ref MatchControl))
{
if (strFile != strFileOldFull)
{
ioWriterFind.WriteLine("\n--- " + strFile + " ---\n");
strFileOldFull = strFile;
}
Console.WriteLine(strFindFull);
ioWriterFind.WriteLine(strFindFull);
} // while(docRange.Find.Execute
} // for(nSec = 1; nSec <= doc.Sections.Count)
} // foreach (string strFind in strListFind)
((Word._Document)doc).Close(ref saveChanges, missing, missing);
} //foreach(string strFile in strArrFindFileName)
((Word._Application)word).Quit(ref saveChanges);
ioWriterFind.Close();
} // FindString()
идет поиск строки. А как задать поиск строки с учетом ее форматирования? Например, найти строку с подчеркиванием, полужирную, наклонную или же со всеми этими форматированиями вместе? Проект прикрепил.