How to replace an image in the header

S

saidevakumar

Hi,

I have a ms word 2003 document. I inserted an image into the header of the
document using Insert->Picture->From File.

I want to replace the image when the document is opened.
When the document is opened, it runs a macro which should find the image and
replace it with my own image.

In the macro, when I try to access the Header with the following code.
MsgBox
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Shapes.Count,
vbOKCancel, "Shapes"
This is always returning 0, inspite of having an image in the header.

For the headers collections there is no InlineShapes object available also.

Is there any other way to access the images in the word 2003 document.

Any help is of great use.

Thanks
Sai
 
L

Lene Fredborg

If the wrapping style of the image is "In line with text", your image is an
InlineShape. You can access the InlineShape if you use the Range object:

MsgBox
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.InlineShapes.Count, _
vbOKCancel, "Shapes"

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
S

saidevakumar

Thanks. I got it.

Lene Fredborg said:
If the wrapping style of the image is "In line with text", your image is an
InlineShape. You can access the InlineShape if you use the Range object:

MsgBox
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.InlineShapes.Count, _
vbOKCancel, "Shapes"

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 

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