1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79:
| Code Snippet
object VerbIndex = 1;
object missing = Type.Missing;
Word.Document doc = app.ActiveDocument as Word.Document;
foreach (Word.InlineShape inlineShape in doc.InlineShapes)
{
if(inlineShape.OLEFormat.ProgID != null)
{
switch (inlineShape.OLEFormat.ProgID)
{
case "PowerPoint.Show.12":
inlineShape.OLEFormat.DoVerb(ref VerbIndex);
PowerPoint.Application ppt = Marshal.GetActiveObject("PowerPoint.Application") as PowerPoint.Application;
ppt.ActivePresentation.SaveAs(@"C:\testPPT.pptx", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsPresentation, Microsoft.Office.Core.MsoTriState.msoTrue);
ppt.Quit();
break;
case "Excel.Sheet.12":
inlineShape.OLEFormat.DoVerb(ref VerbIndex);
Excel.Application excel = Marshal.GetActiveObject("Excel.Application") as Excel.Application;
excel.ActiveWorkbook.SaveAs(@"C:\testBOOK.xlsx", missing, missing, missing, missing, missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, missing,
missing, missing, missing, missing);
excel.Workbooks.Close();
excel.Quit();
break;
case "Word.Document.12":
Word.Document document = inlineShape.OLEFormat.Object as Word.Document;
object fileName = @"C:\testDOC.docx";
document.SaveAs(ref fileName, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
break;
default:
break;
}
}
} |