Sub FindImagesDim doc As Word.Document, shp As Word.Shape, iShp As Word.InlineShapeSet doc = ActiveDocumentFor Each shp In doc.ShapesIf shp.Type = msoLinkedPicture Or shp.Type = msoPicture Then'do somethingEnd IfNextFor Each iShp In doc.InlineShapesIf iShp.Type = wdInlineShapeLinkedPicture Or iShp.Type = wdInlineShapePicture Then'do somethingEnd IfNextEnd SubHope this helpsKind Regards, Rich. Depending on the options setting of Word for how images are inserted they can be either in either the Shapes or InlineShapes collection. These pictures are ordinary jpeg that were inserted manually, these generally would fall under inlineshape or shape?If the pictures are already in the document then you should just need to iterate through the collection. If the photo has been embedded in the document as a file you should be able to extract the fileand use it.Cindy Meister, VSTO/Word MVP. Hi GuiLinKwekWord has no built-in functionality for connecting with PictureBox control on a Windows Form (I assume that's what you're referring to).Using Word's automation interface your only possibility would be to COPY the picture to the Clipboard, then your code would need to retrieve it from the Clipboard and paste it into the PictureBox (assuming the control would support that).The other possibility would involve working with the Word Open XML in the document Zip package, meaning the document would have to be closed, not open in Word. If the pictures are static, you might consider adding an Image control for each one, then simply changingthe zOrder according to the user's selection via a listbox/combobox.CheersPaul EdsteinMS MVP - Word. To load a picture into an Image control at runtime, you need to use the LoadPicture method, which requires the picture's filename & path. Unless it's a linked picture, a picture in a document doesn't have a filename & path of its own.If it's a linked picture, it's easy enough to retrieve the filename & path of the source file the process is the same for Shapes and InlineShapes. There's also a Shape collection.Cindy Meister, VSTO/Word MVP. The Range.WordOpenXML property could theoretically give you the image information aspart of the OPC flat file package it returns, probably as base 64, but you'd have to test it.Please also note that not all graphics content is formatted as an InlineShape.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |