The problem is, I'm creating a new shape picture to replace a previous one. However, even tough the new shape properties Top and Left are exactly the same as the previous picture, the new shape gets dislocated. This happens on a header shape. I believe there is some sort of hidden property I'm not able to find on VBA watch.
I'm adding the code as this (A simplified version):
For i = ActiveDocument.Sections(1).Headers(1).Shapes.count To 1 Step -1
'shape to delete:
set shp2del = ActiveDocument.Sections(1).Headers(1).Shapes(i)
'shape to add
Set shp2 = ActiveDocument.Sections(1).Headers(1).Shapes.AddPicture(replace_path, False, True, shp2del.Left, shp2del.Top, shp2del.width, shp2del.height)
shp2del.delete
next i
And voilá, it creates the object shp2, deletes shp2del.. with a small problem, in some documents, it doesn't stay in position.
I tried many things, redefining shp2.top and shp2.left after creating, looked for relative positions properties, anchor object properties, compared with the shape to delete and new shape, and everything seems to be the same unless I'm (most likely) missing a property.
I also tried to create a macro and see the code that would change the new shape into position, but unfortunately while creating a macro word doesn't allow to handle pictures very well..
The only hint I found was this one, but to change this programmatically, I don't know how.
After the answer from m4o_tim the options that word displays are more accurate, still the distances remain incorrect on the final document
I'm also curious about the lock anchor and allow overlap, but this is surely hidden within shp2.anchor and I'll try those out.
Regarding the absolute position I couldn't find a property that I could set. Thanks for the help m4o_tim, is there anyone else who can help?
Update 2: Finally its working, basically what's needed to do is to re-define top and left positions after the settings
With newshp
.WrapFormat.Type = oldshp.WrapFormat.Type
.RelativeHorizontalPosition = oldshp.RelativeHorizontalPosition
.LeftRelative = oldshp.LeftRelative
.RelativeVerticalPosition = oldshp.RelativeVerticalPosition
.TopRelative = oldshp.TopRelative
.Top = oldshp.Top
.Left = oldshp.Left
.LockAnchor = oldshp.LockAnchor
End With
After this it was working perfectly. Thanks m4o_tim
Update 3: I realized this luckily worked in only one section. The reason for such is the anchor position.
If I compare shp2del.Anchor.Information(wdVerticalPositionRelativeToPage) with shp2.Anchor.Information(wdVerticalPositionRelativeToPage)
I will get different values. I will open up a new question about this. Thanks everyone.

