我正在尝试使用以下方法替换 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
但是新图像不会放在以前的图像位置!
问题是什么?如何将新图像准确地放置在以前的图像位置上?
谢谢