That's great Tom
You will probaly need a little more error checking or at least On Error Resume Next!
I've added a couple of things I have learned over the years which are often useful so I'll explain them.
[vba] Set oshp = ActiveWindow.Selection.TextRange.Parent.Parent[/vba]
When you ask people to select a shape with text they often put the cursor in the text effectively selecting the textrange.
The parent of TextRange is TextFrame and it's Parent is the Shape hence Parent.Parent
The use of a loop and StrPtr (string pointer) in the input box. The loop simply ensures they enter a number not eg "One" or "What?"!! The problem comes if the hit cancel, Input box sees this as Not a number and keeps looping. StrPrt is a little known feature that points to the address of the string in memory. It will do this even if the string is "" but not if there is NO string at all as when cancel is pressed.
How it works
Finds the name of the shape which will be Rectangle xx
Works out the value of xx and then the name of the other shapes by adding one to the value in the name on each loop. The delete Lines feature is maybe a little dodgy as the user may have deleted borders. Definitely add On Error Resume Next here.
Here endeth the lesson!




Reply With Quote