
Replacing a pictures properties with another pictures properties
Hi,
I have a Word document with some text and a picture. The picture is places
below the text.
I want to replace the picture with another picture. The new picture could be
smaller or larger, so I scale the new picture to fit the old size.
I have managed to set the picture size, but I have problems getting the same
placement even though I copy the height, width, top and left. I think it is
the anchoring that I havent been able to copy, but I am unsure what in the
anchor to copy.
Do you have any suggestions how to get the same anchoring as the old picture
or maybe the anchoring is'nt the problem?
Here is my code:
' Insert the new picture
Set shpNewPicture=
objWord.ActiveDocument.Shapes.AddPicture( _
FileName:="D:\Prosjekter\Exact\InterdevProsjekt\Exact\Exact_Local\Dokument\t
est.bmp", _
LinkToFile:=False, _
SaveWithDocument:=True)
' Transfer the properties to the new picture
With shpOriginalPicture
shpNewPicture.LockAspectRatio = msoFalse
shpNewPicture.Height = .Height
shpNewPicture.Width = .Width
shpNewPicture.Left = .Left
shpNewPicture.Top = .Top
shpNewPicture.WrapFormat.Type = .WrapFormat.Type
shpNewPicture.WrapFormat.Side = .WrapFormat.Side
shpNewPicture.Fill.Visible = .Fill.Visible
shpNewPicture.Line.Visible = .Line.Visible
shpNewPicture.Anchor.Start = .Anchor.Start
shpNewPicture.Anchor.End = .Anchor.End
shpNewPicture.TextFrame.MarginBottom =
.TextFrame.MarginBottom
shpNewPicture.TextFrame.MarginLeft =
.TextFrame.MarginLeft
shpNewPicture.TextFrame.MarginRight =
.TextFrame.MarginRight
shpNewPicture.TextFrame.MarginTop =
.TextFrame.MarginTop
shpNewPicture.Anchor.Characters = .Anchor.Characters
shpNewPicture.Anchor.Characters = .Anchor.Characters
End With