Swapping Header Logo

  • Thread starter Steven Craig Basham
  • Start date
S

Steven Craig Basham

Hello,
I'm not new to programming, but I AM new to working with MS Word. I'm
wondering where I might start to look in order to access a Ole graphic
inserted into the header of a word document (it's a jpg logo), so that I can
replace it with our new jpg logo. We have over 10,000 documents that need
the logo replaced and I thought the best way would be to write a vp app to
swap them out for a list of files I send it. However just messing around
with the toolbox for the word app... I couldn't immediately see where I can
access the image from the header at. Can someone point me out in the right
direction?

Thank you so much,
Steven Craig Basham
 
H

Helmut Weber

Hi Steven,
10,000 files is a lot. A good solution would require a log file,
a handler for all kinds of errors and much more. In case that there
is only one logo in the header, and it is of comparable size, you are
lucky. Then the question, which shape or inlineshape has to be
replaced, doesn't have to be answered.
What remains is a loop over all headers in all sections of a document.
I am assuming, that a loop over 10,000 docs is not a problem,
though it could be. Strange, that inlineshapes appear in a range,
whereas shapes don't.
Untested pseudocode for accessing all headers in a doc:
Sub FindLogo()
' wdHeaderFooterEvenPages = 3
' wdHeaderFooterFirstPage = 2
' wdHeaderFooterPrimary = 1
Dim s As Long ' the sections
Dim h As Long ' the headers
With ActiveDocument.Sections
For s = 1 To .Count ' the sections
For h = 1 To 3 ' all kinds of headers
MsgBox .Item(s).Headers(h).Shapes.Count
' delete and replace
MsgBox .Item(s).Headers(h).Range.InlineShapes.Count
' delete and replace
Next
Next
End With
End Sub
Use the macro-recorder for coding of deleting and replacing.
Difficult!
HTH
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 

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