View Single Post
 
Old 06-03-2017, 12:18 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

If you know how to do it, then set a range to the location of the image you are removing and then insert an image in the range e.g. the following will replace the first inline image in each header footer with the named image.

Code:
Sub ReplaceImage()
Dim oHeader As HeaderFooter
Dim oRng As Range
    For Each oHeader In ActiveDocument.Sections(1).Headers
        If oHeader.Exists Then
            If oHeader.Range.InlineShapes.Count > 0 Then
                Set oRng = oHeader.Range.InlineShapes(1).Range
                oRng.Text = ""
                oRng.InlineShapes.AddPicture _
                        FileName:="C:\Path\filename.jpg", _
                        LinkToFile:=False, _
                        SaveWithDocument:=True
            End If
        End If
    Next oHeader
lbl_Exit:
    Set oHeader = Nothing
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote