public void Distribution(List<string> replaceList) { foreach (string s in replaceList) { int i = 0; Dock doc = new Dock(DocumentMode.CreatFromTemplate, document.Document.Path + "\\" + document.Document.Name); FindAndReplace(doc.App, "#UserName", s); object pathToSave = @"C:\TestWord\test" + i.ToString() + ".docx"; Object fileFormat = WdSaveFormat.wdFormatDocument; doc.Document.SaveAs2(pathToSave, fileFormat); doc.Document.Close(WdSaveOptions.wdSaveChanges); doc.App.Quit(WdSaveOptions.wdSaveChanges); } }
public void CreateDocument() { document = new Dock(DocumentMode.Create); }
public void LoadDocument(string Path) { try { document = new Dock(DocumentMode.Load, Path); object findText = "И все случайности, которые, случившись, становятся причиной других случайностей, становятся причиной других случайностей."; object replaceText = "ТЕСТ пройден"; FindAndReplace(document.App, findText, replaceText); paragraphs = document.Document.Paragraphs; text = "";// document.Document.Content.Text; foreach (Paragraph p in paragraphs) { text += p.Range.Text + "\n"; } } catch (Exception ex) { throw ex; } }