public static void DoSomething(string docPath) { Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application(); try { Document doc = wordApp.Documents.Open(docPath, ReadOnly: false, Visible: false, AddToRecentFiles: false); doc.Activate(); for(int i = doc.InlineShapes.Count; i > 0; i--) { if (doc.InlineShapes[i].Type == WdInlineShapeType.wdInlineShapeLinkedOLEObject) { if (doc.InlineShapes[i].LinkFormat.SourceName.Split('.')[doc.InlineShapes[i].LinkFormat.SourceName.Split('.').Length - 1] == "docx") DoSomething(doc.InlineShapes[i].LinkFormat.SourceFullName); doc.InlineShapes[i].LinkFormat.Update(); doc.Save(); } } (doc as _Document).Close(); (wordApp as _Application).Quit(); } catch { } System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)