Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Word = Microsoft.Office.Interop.Word;
- class Program
- {
- static void Main(string[] args)
- {
- Word.Application app = new Word.Application();
- Object fileName = @"D:\тест.docx";
- Object missing = Type.Missing;
- app.Documents.Open(ref fileName);
- Word.Find find = app.Selection.Find;
- find.Text = "<NAME>";
- find.Replacement.Text = "ТВОЙ ТЕКСТ ДЛЯ ВСТАВКИ";
- Object wrap = Word.WdFindWrap.wdFindContinue;
- Object replace = Word.WdReplace.wdReplaceAll;
- find.Execute(FindText: Type.Missing,
- MatchCase: false,
- MatchWholeWord: false,
- MatchWildcards: false,
- MatchSoundsLike: missing,
- MatchAllWordForms: false,
- Forward: true,
- Wrap: wrap,
- Format: false,
- ReplaceWith: missing, Replace: replace);
- app.ActiveDocument.Save();
- app.ActiveDocument.Close();
- app.Quit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment