extract images programaticaly from word document

H

henry

Hello,
I want to change a bitmap image in word doc using C# but I can't seem to
understand the Document structure, break the document up in pages or
differentiate the bitmap image from other shape object. Please, I will
appreciate your assistance and feel free to elaborate more on any point or
use examples. Thank you.
 
J

Jean-Guy Marcil

henry said:
Hello,
I want to change a bitmap image in word doc using C# but I can't seem to

What do you mean by "change"?
What do you want to do to the images?
understand the Document structure, break the document up in pages or
differentiate the bitmap image from other shape object. Please, I will
appreciate your assistance and feel free to elaborate more on any point or
use examples. Thank you.

Meanwhile, here is a sample sub that determines if the current selction is a
picture or not. Remember that there are inlineshapes and floating shapes,
they are a different collection.


Sub IsSelectionPicture()

If Selection.InlineShapes.Count > 0 Then
If Selection.InlineShapes(1).Type = wdInlineShapePicture Then
MsgBox "The selection is an InlineShape picture."
Exit Sub
End If
End If

If Selection.ShapeRange.Count > 0 Then
If Selection.ShapeRange(1).Type = msoPicture Then
MsgBox "The selection is a floating picture."
Exit Sub
End If
End If

MsgBox "The selection is neither a floating picture nor an InlineShape
picture."

End Sub
 
H

henry

Hello Jean-Guy,

You sample code helped a lot but I still need a little help. Actually I want
to identify a particular picture within the document and replace that picture
with another picture entirely. I am not sure if there is a way to
differentiate a particular picture/image from other images/pictures embedded
within a word document. for example if (picture1 == picture2) do that
.......?. I will appreciate any assistance. Thank you.
 
J

Jean-Guy Marcil

henry said:
Hello Jean-Guy,

You sample code helped a lot but I still need a little help. Actually I want
to identify a particular picture within the document and replace that picture
with another picture entirely. I am not sure if there is a way to
differentiate a particular picture/image from other images/pictures embedded
within a word document. for example if (picture1 == picture2) do that
......?. I will appreciate any assistance. Thank you.

Word cannot compare two pictures in order to determine if the content is
identical. Once they are embedded, their original name is gone. You could do
that if you linked the picture in Word instead of embedding it. Then you
could compare the field content (A linked picture is a field).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top