これを使用してMS Wordヘッダーの画像を置き換えようとしています:
For Each tmp In ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Shapes
If tmp.Type = msoPicture Then
Set dShape = tmp
End If
Next
Dim w, h, t, l As Single
Dim lic As Long
Dim rhp As WdRelativeHorizontalPosition
Dim rvp As WdRelativeVerticalPosition
dShape.RelativeVerticalPosition = wdRelativeVerticalPositionMargin
dShape.RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
With dShape
w = .Width
h = .Height
t = .Top
l = .Left
lic = .LayoutInCell
End With
Dim shp As Shape
Set shp = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Shapes.AddPicture("C:\aa.jpg", False, True, l, t, w, h)
shp.RelativeVerticalPosition = rvp
shp.RelativeHorizontalPosition = rhp
shp.LayoutInCell = lic
dShape.Select
dShape.Delete
しかし、新しい画像は前の画像の位置に配置されません!
何が問題ですか?新しい画像を前の画像の位置に正確に配置するにはどうすればよいですか?
ありがとう