Positioning of Shapes in Word 2007

G

George B

Can anyone explain to me what is going on here?

I generate a shape and a duplicate
Set shp1 = shpCanvas.CanvasItems.Addcurve(SafeArrayOfPoints:=sngArray)
Set shp2 = shp1.Duplicate

The duplicate is generated at an offset from the original, as documented in
the help files.

I then attempt to move the duplicate to be at the same height as the
original:
shp2.Top = shp1.Top

The duplicate now moves to the top of the canvas, much higher than the
position of the original. What am I doing wrong?
 
C

Cindy M.

Hi George,
I then attempt to move the duplicate to be at the same height as the
original:
shp2.Top = shp1.Top

The duplicate now moves to the top of the canvas, much higher than the
position of the original. What am I doing wrong?

The little piece of the puzzle that you're missing is what the Shape is
positioned relative to. By default, most Shapes are positioned relative
to the "container" (page or canvas), not to the anchoring paragraph. In
the UI, this difference corresponds to whether the "Move with text"
option is active (relative to paragaph) or not (relative to container).

In the object model, look for the "Relative..." properties of the Shape
object.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
G

George B

Cindy M. said:
Hi George,


The little piece of the puzzle that you're missing is what the Shape is
positioned relative to. By default, most Shapes are positioned relative
to the "container" (page or canvas), not to the anchoring paragraph. In
the UI, this difference corresponds to whether the "Move with text"
option is active (relative to paragaph) or not (relative to container).

In the object model, look for the "Relative..." properties of the Shape
object.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)


This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)

Cindy,

Relative properties are not relevant - this is not a picture or OLE object.
When I look at the shape properties in Debug mode, shp2.Top is not equal to
shp1.Top, despite having set them equal. Any other thoughts?
 
C

Cindy M.

Hi George,
Relative properties are not relevant - this is not a picture or OLE object.
When I look at the shape properties in Debug mode, shp2.Top is not equal to
shp1.Top, despite having set them equal. Any other thoughts?

If it's a member of the SHAPES collection, then relative properties ARE
relevant.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
T

Tony Jollans

Canvasses are horrible!

To answer your question - no, I can't really explain it.

When you duplicate your shape, the new Shape is not properly on the canvas,
and when you change its Top property it is positioned relative to the page
and the canvas is extended so that it still fits inside - this leaves shp1
where it was but because it is in the canvas, its (relative to the canvas)
top position is altered.

I think you can work around it with a pretty horrible bit of code like this
....

....
Set shp2 = shp1.Duplicate

SaveTop = shpCanvas.Top
SaveRel = shpCanvas.RelativeVerticalPosition

shpCanvas.RelativeVerticalPosition = wdRelativeVerticalPositionPage
shpCanvas.Top = shp1.Top

shp2.Top = shp1.Top

shpCanvas.RelativeVerticalPosition = SaveRel
shpCanvas.Top = SaveTop
 

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