1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
Object oMissingOpen = System.Reflection.Missing.Value;
Object oReadOnly = true;
Object oFile = (Object)"RepertoireFichier";
Microsoft.Office.Interop.Word.Application wordAp = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document wordDoc = new Microsoft.Office.Interop.Word.Document();
wordDoc = wordAp.Documents.Open(ref oFile, ref oMissingOpen, ref oReadOnly, ref oMissingOpen);
wordAp.Visible = true;
object oMissingFind = System.Type.Missing;
foreach (Word.Range tmpRange in wordDoc.StoryRanges)
{
tmpRange.Find.Text = "MotRecherché";
tmpRange.Find.Replacement.Highlight= 1;
tmpRange.Find.Wrap = Word.WdFindWrap.wdFindContinue;
object replaceAll = Word.WdReplace.wdReplaceAll;
tmpRange.Find.Execute(ref oMissingFind, ref oMissingFind, ref oMissingFind, ref oMissingFind, ref oMissingFind, ref oMissingFind, ref oMissingFind, ref oMissingFind, ref oMissingFind, ref oMissingFind, ref replaceAll, ref oMissingFind, ref oMissingFind, ref oMissingFind, ref oMissingFind);
}
wordAp.NormalTemplate.Saved = true; |
Partager