none
Old vs New... (Shapes collection) RRS feed

  • Question

  • Before Word 2010, floating shapes displayed green little circles in the corners when you selected them. Now, they have white little squares and a pop up menu attached to them.

    If you have a document set to be compatible with previous versions, you may have both types of shapes in it.

    The newer ones cannot be selected with the Select Object tool. Also, the Selection pane is not available with backward compatible documents.

    Finally, neither can you select both types with VBA, if you try you get an error:
    Error -2147467259
    "Method 'Select' of object 'ShapeRange' failed"

    Is there a way to tell them apart with code? Can we differentiate between a legacy shape and a "2010 and up" one by testing some property via VBA?

    Friday, April 22, 2016 6:53 PM

Answers

  • OK, I think I've found something.

    The ".Title" property was introduced in Word 2013, this might be useful.

                On Error Resume Next
                If .ShapeRange(i).Title = "" Then
                    If Err.Number = 445 Then
    

    The code above  allows me to detect if it is a "new" shape or a "legacy" one.

    So far so good, I have two Subs, one to select "Legacy" (prior to Word 2013) shapes and one to select the newer ones. 

    Unless someone has something better, I can go with that for now.

    Thanks for your help.

    Monday, April 25, 2016 4:37 PM

All replies

  • >>>The newer ones cannot be selected with the Select Object tool. Also, the Selection pane is not available with backward compatible documents.

    Finally, neither can you select both types with VBA, if you try you get an error:
    Error -2147467259 
    "Method 'Select' of object 'ShapeRange' failed"<<<

    According to your description, I have made a sample to try to reproduce this issue, unfortunately, I can't. So I suggest that you could make sure whether you are able to select both shapes with CRTL manually.

    In addition could your provide more information about your issue, for example sample file, sample code and screenshot etc., that will help us reproduce and resolve it.

    Thanks for your understanding.
    Monday, April 25, 2016 5:41 AM
  • Thanks for the reply.

    We are talking about floating shapes.

    OK, visually, the "legacy" shapes, those handled as such until Word 2007 look like that:

    See the dark handles and the Green Rotate Handle?
    Those shapes can be selected with the Drag/Select function of the Select Objects tool.

    Notice how the Pill picture was not selected by the Select Objects tool? It's because it's a new type of shapes, i.e. Word 2010 and up. Visually, the handles are different:

    White handles and a dynamic menu option in top right corner.

    Those shapes are supposed to be selected by the Selection Pane, but when working in compatibility mode, the Selection Pane is not available. So if I have many such shapes on a page, I cannot select them all in one pass, I have to CTRL-Click, or use a macro (see my other post--the one you helped me with already). However, the macro will not work if those two types are on the page (Word 2007 and Word 2010+). I get an error as described in the OP. Also CTRL-Clicking will not work when trying to click-select the two types.

    So I was wondering if there was a way to tell them apart programmatically. Maybe detect the Dynamic menu?

    Thanks.

    Monday, April 25, 2016 2:52 PM
  • OK, I think I've found something.

    The ".Title" property was introduced in Word 2013, this might be useful.

                On Error Resume Next
                If .ShapeRange(i).Title = "" Then
                    If Err.Number = 445 Then
    

    The code above  allows me to detect if it is a "new" shape or a "legacy" one.

    So far so good, I have two Subs, one to select "Legacy" (prior to Word 2013) shapes and one to select the newer ones. 

    Unless someone has something better, I can go with that for now.

    Thanks for your help.

    Monday, April 25, 2016 4:37 PM
  • Hi, Jean-Guy Marcil

    Congratulation, thanks for your sharing your solution, that will help other community member when they have same issue.
    Tuesday, April 26, 2016 5:52 AM