Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word, naming shapes/inlineshapes (Win2K, O2K-pro UK)

    Hi,

    I've got a document with multiple shapes on. Some are added through autotexts, some during runtime.
    It seems extremely hard to identify specific shapes in order to adjust and position those.

    Properties and naming possibilities seems also rather limited.
    Then it struck my mind that I've heard about "hidden properties". Here I'm wondering if the shapes and InlineShapes collections also have such ??
    Does anyone know if this is the case - how to access them and potentially also do these 2 items have a ".tag" property....??

    Any guidance are highly appreciated.

    Thanks
    ;o) Henrik
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

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

    Re: Word, naming shapes/inlineshapes (Win2K, O2K-pro UK)

    As far as I know, Shapes and InlineShapes don't have properties like Tag. They do have a name, which is read/write, so you can assign a new name if you like, and refer to that name later on.

    If you add a shape in code, you can assign a shape object and refer to that later on:

    Dim sh As Shape
    Set sh = ActiveDocument.Shapes.Add(msoShapeRectangle, 10, 20, 50, 30)
    ...
    ' other code
    ...
    sh.Left = 70
    sh.Top = 60

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Word, naming shapes/inlineshapes (Win2K, O2K-pro UK)

    Hans,

    I think Word's Document shapes have a method AddShape rather that Add.


    Set sh = ActiveDocument.Shapes.AddShape(msoShapeRectangle, 10, 20, 50, 30)

    works for me.

    Also to give the shape a permanent name

    Sh.Name = "Name"

    should work.

    Andrew C

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

    Re: Word, naming shapes/inlineshapes (Win2K, O2K-pro UK)

    Andrew, you're right about AddShape. I typed the message directly instead of copying and pasting my test code <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30>.

    Word assigns a Name to a shape like "Box 3"; one can use this, or, as I indicated somewhat obscurely, and you show, assign a name in code.

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

    Re: Word, naming shapes/inlineshapes (Win2K, O2K-pro UK)

    Hi Henrik,

    The following macro reports all embedded shapes in a document.

    Sub FindShapes()
    If ActiveDocument.Shapes.Count > 0 Then
    For Each Shp In ActiveDocument.Shapes
    ShapeNames = ShapeNames & Shp.Name & vbCr
    Next Shp
    MsgBox "Found Shapes:" & vbCr & ShapeNames
    End If
    End Sub

    Change
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  6. #6
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word, naming shapes/inlineshapes (Win2K, O2K-pro UK)

    Thanks a lot for your tips - much appreciated.

    I need to specify a little bit here. What I'm adding is a "picture from file...", but your tips works just as fine - no problem.

    Problem turned out to be to get hold of the picture once inserted...
    Picture is inserted in header/footer and just looping through 'activedocument.shapes' returns nothing...
    What I wasn't aware of initially was, that to be sure to got hold of all shapes when looping through the shapes collection in a document, I need also to loop through eg. ActiveDocument.Headers(wdHeaderFooterPrimary).Shap es or similar footer.

    I didn't find this obvious, but a lot seems now clearer - thanks.


    ;o) Henrik
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

Posting Permissions

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