public void UpdateTOC(string file1, string file2) { using (var mainDoc = WordprocessingDocument.Open(file1, false)) using (var resultDoc = WordprocessingDocument.Create(file2, WordprocessingDocumentType.Document)) { // copy parts from source document to new document foreach (var part in mainDoc.Parts) resultDoc.AddPart(part.OpenXmlPart, part.RelationshipId); // perform replacements in resultDoc.MainDocumentPart // ... } } }
Guid.NewGuid().ToString()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)