Incorrect Shape to Anchor relative position returned by Word.

M

Marc

If a shape is inserted in word using either relative to
paragraph or relative to character setting and the shape
is above the anchor, the anchor moves to the right of the
shape but Shape.Top and Shape.Left fails to indicate this
change, as a result, calculating the position of the shape
on the page returns an incorrect value.

For example:

- Start with an empty word document
- Insert Picture from file
- Format Picture (right click) -> Layout -> Square
- Drag the image in the middle of the blank page
- Display the paragraph/formating characters

ok, so when you click on the picture, you should see its
anchor at the top/left of the page.

At this point, if you try:

ActiveDocument.Shapes(1).Left and .Top, you'll get a
correct value.

Move the shape closer and closer to its anchor and the
value gets closer to (0,0).

Now move the picture directly on the top/left corner of
the margins, where the anchor is. The anchor moves right.

The values returned are (0,0) BUT the anchor has moved and
if you call :

hr = pAnchor->get_Information
(Word::wdHorizontalPositionRelativeToPage,&vHPos);
hr = pAnchor->get_Information
(Word::wdVerticalPositionRelativeToPage,&vVPos);

you get the NEW anchor position. Adding the two together
returns an incorrect result, telling me that the shape is
where the Anchor is which is not true.

By the way, you can reproduce this bug within Word itself
very easily. As the picture is at teh top left corner and
the anchor is right of it, right click the picture, select
Format Picture, Layout Tab, Advanced, and change the 'To
the right of' and 'Below' settings to 'Margin'. Press
OK/OK and ... the picture moves to the right. Even word
thinks gets it wrong.

The real question is:

I need a formula that return the correct picture postion
relative to either the margins or the page corners.

Thanks
 
C

Cindy M -WordMVP-

Answer received in one of the word.vba groups.

Personal note: if you hadn't posted so many separate
messages you might have gotten a response much sooner. No
one wants to duplicate effort when time is at a premium, so
I passed by this a number of times, being unsure whether
one of the other messages had received an answer.

Cindy Meister
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top