Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Jul 2002
    Location
    Hampshire, United Kingdom
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Positioning shapes in a canvas (Word 2003)

    I have a drawing canvas in a word document containing a number of shapes. I want identify the position of the shapes and reposition them. However when I show the .top and ,left properties of the child shapes
    selection.ShapeRange(1).CanvasItems(1).top
    It always returns the same values regardless of their position. Setting this value seems to have no effect. So how do I reposition objects in a canvas? I can move them manually but of course just to make things easy the macro recorder does not allow you to record a repositioning sequence.
    Any suggestions?

    Pete

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Positioning shapes in a canvas (Word 2003)

    Do you have a particular reason for using a canvas? I've always found it to be a pain in the behind, and I turn it off in every installation of Word as soon as I can. The behavior that you describe is one more reason to avoid it.

  3. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Positioning shapes in a canvas (Word 2003)

    Hi Pete,

    Are the shapes grouped? That might have something to do with it.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Positioning shapes in a canvas (Word 2003)

    No, even if I create just a single shape on a new canvas, VBA reports its Top and Left properties as -1638.35 regardless of where I drag the shape within the canvas.

  5. #5
    New Lounger
    Join Date
    Jul 2002
    Location
    Hampshire, United Kingdom
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Positioning shapes in a canvas (Word 2003)

    Hans - like you I normally never use a canvas, but I thought that for this application is was probably the right thing to do. I have about 40 shapes in my drawing that I want to add to a document using an autotext entry. I will then replace one of the shapes with a different one using the exact same coordinates. I had thought that by using a canvas it would be easier to keep the shapes together, but it looks as though I was probably wrong. Unless anyone come up with a solution I'll probably just stick them inside a table cell which normally works quite well.

    Thanks

    Pete

  6. #6
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: Positioning shapes in a canvas (Word 2003)

    What about this? I just tested this in Word 2003 and it worked perfectly, though I don't have my shapes on a canvas -- like Hans, I hate that old canvas. In fact, it WON'T work with the canvas, but you don't need that, do you?

    Create a Text Box and give it a name. I use this VBA code to name a shape:
    <pre>Sub SetAShapeName()
    Dim strName
    strName = InputBox("Type the name of the shape")
    Selection.ShapeRange.Name = strName
    MsgBox "The shape is named " & strName, vbOKOnly
    End Sub</pre>

    And I use this if I forget it...
    <pre>Sub GetAShapeName()
    Dim strName
    strName = Selection.ShapeRange.Name
    MsgBox "The shape is named " & strName, vbOKOnly
    End Sub</pre>

    I've found you can name any shape -- which makes it much easier to manipulate later. In my example, name your text box "Title1" then use this code to select it and have it return its location:
    <pre>Sub WhereAmI()
    Dim strL, strT
    ActiveDocument.Shapes("Title1").Select
    strL = Selection.ShapeRange.Left
    strT = Selection.ShapeRange.Top
    MsgBox "Left is " & strL & " and Top is " & strT, vbOKOnly, "Coordinates"
    End Sub</pre>

    So you'd find and select the shape you want to replace, save its coordinates, delete the shape (?), then add the new shape via AutoText, select it by name (because you named it before you saved it as AutoText...), then move it to the saved coordinates.

    Seems to me you might be able to adapt this to do what you want.
    Kim <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>

  7. #7
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: Positioning shapes in a canvas (Word 2003)

    I left out a couple of things in my previous post.

    A graphic (rather than a text box) cannot be in-line.
    A graphic needs to be move-able. Set its wrap style as In front of text, so I can easily float it around the page like a text box can.
    The coordinates will refer to the distance from the Shape's anchor point, so bear this in mind as you try to manipulate it. Your shapes should all have the same anchor point when saved as AutoText, so you know where you're starting.

    ...On the other hand, you might find the table option more workable.
    K <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>

  8. #8
    New Lounger
    Join Date
    Jul 2002
    Location
    Hampshire, United Kingdom
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Positioning shapes in a canvas (Word 2003)

    Thanks Kim.
    I've always found naming shapes very helpful. It's a shame Word does not display the name of the shape in the way that Excel does - but that's another matter. I think I'll dump the canvas idea...

    Pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •