Information from images in headers not being shown

R

Robin

I have a document and in the header of that document there are various
images. These have been inserted and linked. I can see the links in the Links
dialog. I have a script that should at least show the path and filename of
these images. It only does that for other images that are not in the header.
Nobne of the images in the document are inline, and while this script works
for the "body" images, it does not return any details on the "header" images.

Sub sd()

Dim myShape As Shape

For Each myShape In ActiveDocument.Shapes
MsgBox myShape.LinkFormat.SourcePath
MsgBox myShape.LinkFormat.SourceName
Next myShape

End Sub

Any suggestions why?

I have also tried something like this...

Sub x()

Dim s As Section
Dim j As Shape

For Each s In ActiveDocument.Sections
For Each j In s.Headers(wdHeaderFooterPrimary).Shapes
If j.Type = 15 Then
MsgBox j.LinkFormat.SourcePath
MsgBox j.LinkFormat.SourceName
End If
Next j

For Each j In s.Headers(wdHeaderFooterEvenPages).Shapes
If j.Type = 15 Then
MsgBox j.LinkFormat.SourcePath
MsgBox j.LinkFormat.SourceName
End If
Next j

Next s

End Sub

And this again returned nothing?

thanks
Robin
 
J

Jay Freedman

As your second macro suggests that you already know, the
ActiveDocument.Shapes collection contains only the shapes that are
anchored in the main text.

The problem in the second macro is the hardcoded Type value 15 that
you're comparing to. The Shape.Type values are members of the
msoShapeType enumeration. The value 15 corresponds to msoTextEffect,
which indicates a WordArt object. If you want linked pictures, you
should check for j.Type = msoLinkedPicture, which has a numeric value
of 11. I recommend using the mnemonics instead of the numeric values
in all cases, as they would prevent problems like this one.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

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