Replace graphic in Header (Word 2007)

Hi There,
I would appreciate if you could steer me in the right direction.
I need to write a batch routine to replace the logo in a couple of hundred word documents.
I will be using visual studio 2010 (visual basic and not C#)
The documents in question is respectively Word 2003 and 2007.
I would appreciate some tips or maybe even a snippet or two
regards
Zack

Hi Zack,

Thanks for your inquiry. Could you please attach a sample document where you need to replace a logo? I will check it and provide you more information or sample code.
Best regards,

Hi Zack,
Thanks for your inquiry.
I think the general algorthim to achieve this will be similar to the code found in the Extracting Images article found here.
In your case you would want to gather the shapes only from the Header instead of in the whole document. You can take a look at the samplecode in the API here to see how gather headers from a document. You can then call GetChildNodes on the particilar header(s) instead of the whole document.
If you have any troubles, please feel free to ask for help and we will assist you.
Thanks,

Attached find two example templates that I want to replace the graphic with another
regards
Zack

Hi
Thank you for additional information. You can try using the code like the following to replace an image with another image:

// Open document.
Document doc = new Document(@"Test001\na22fwf1.doc");
// Get shape.
Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
// We can replace an image if Shape has an image.
if(shape.HasImage)
shape.ImageData.SetImage(@"C:\Temp\test.jpg");
// Save output document.
doc.Save(@"Test001\out.doc");

But you should note that there can be a lot of shapes in the document. So you should have a way to identify shape where you need to replace an image. For example you can try using Shape.Name:
https://reference.aspose.com/words/net/aspose.words.drawing/shapebase/name/
Hope this helps.
Best regards,

Thank you for your assistance!
My routine works.
I converted your code as follows in VB

' Open document.
Dim doc As New Aspose.Words.Document("c:\lltiouhf.doc")
' Get shape.
Dim shape As Aspose.Words.Drawing.Shape = DirectCast(doc.GetChild(Aspose.Words.NodeType.Shape, 0, True), Aspose.Words.Drawing.Shape)
' We can replace an image if Shape nas an image.
If shape.HasImage Then
shape.ImageData.SetImage("C:\Excellence Fit.jpg")
End If
' Save output document.
doc.Save("c:\downloads\out.doc")

regards
Zack

Hi

It is perfect! Please let me know in case of any issues. I will be glad to help you.
Best regards,