简体   繁体   中英

Convert Word.InlineShape to Excel.Workbook c#

There are some excel.workbooks in Word document.

i can get Word.Inline shapes but i need to convert them to Excel.Application

Word.InlineShapes shapes=wordApp.ActiveDocument.InlineShapes;

Those shapes created via

wordApp.Selection.InlineShapes.AddOLEObject("MSGraph.Chart.8", excellApp.ActiveWorkbook.Name, false, false, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

How can i convert them to Excel.Workbook again?

Also i tried ;

Word.InlineShapes shapes = wordApp.ActiveDocument.InlineShapes;

foreach(Word.Shape shape in shapes)
{
     Word.Chart chart = shape.Chart;
}

but it throws unimplemented exception.

Try this:

Word.OLEFormat ole = shape.OLEFormat;
ole.Activate();
Excel.Workbook book = (Excel.Workbook)ole.Object;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM