--- In helpwithvb@yahoogroups.com, "allan_blackford" <allan_blackford@...>
wrote:
>
> How do I go about extracting an image from a word file?
>
It took a while but I finally found enough resources to figure it out. This
must not be a popular subject, since I couldn't find much at all, along with no
repsonses here. Anyway, if anyone wants the vb.net code, here ya go. It may not
be pretty, but it works.
Dim x As Integer
Dim wordAp As New Word.Application
Dim doc As Word.Document
Dim picShape As Word.InlineShape
Dim image As Bitmap
'open word file and keep it hidden
doc = wordAp.Documents.Open(dlgFilePath.FileName, ReadOnly:=True)
doc.ActiveWindow.Visible = False
'array to for images
x = doc.InlineShapes.Count
Dim aryImages(x - 1) As Bitmap
'get shapes from word file
For x = 0 To doc.InlineShapes.Count - 1
picShape = doc.InlineShapes.Item(x)
'select shape and copy as picture to clipboard
picShape.Select()
wordAp.Selection.CopyAsPicture()
'get image from clipboard and put in array
image = Clipboard.GetImage
aryImages(x) = image
Next
'close word file
doc.Close()
frmImages.Show()