View Single Post
 
Old 08-01-2017, 03:21 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,514
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You need to tell Word what to set the position relative to. Try something based on:
Code:
Sub ImageInHeaderFooter()
Application.ScreenUpdating = False
Dim Shp As Shape
With ActiveDocument.Sections(1)

    Set Shp = .Headers(wdHeaderFooterPrimary).Shapes.AddPicture( _
        FileName:="\\URL2Image.jpg", SaveWithDocument:=True)
    
    With Shp
        .LockAnchor = True
        .LockAspectRatio = True
        .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
        .RelativeVerticalPosition = wdRelativeVerticalPositionPage
        .Left = CentimetersToPoints(-0.5)
        .Top = CentimetersToPoints(0.7)
        .Width = CentimetersToPoints(8.2)
    End With
    
    Set Shp = .Footers(wdHeaderFooterPrimary).Shapes.AddPicture( _
        FileName:="\\URL2Image.jpg", SaveWithDocument:=True)

    With Shp
        .LockAnchor = True
        .LockAspectRatio = True
        .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
        .RelativeVerticalPosition = wdRelativeVerticalPositionPage
        .Left = CentimetersToPoints(-2.8)
        .Top = CentimetersToPoints(25.6)
        .Width = CentimetersToPoints(21.8)
    End With
    
End With
Application.ScreenUpdating = True
End Sub
Presumably, you'll need to adjust the .Left values. Note that I've omitted the .Height specifications. Assuming your images already have the correct aspect ratio, locking it before resizing either the .Height or .Width is sufficient.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote