How to return the name from selected shape

F

Finn Petersen

Hi
Does anybody know how to return the name or index number from a selected
shape in Word.
I thought it should be something like this:

msgbox Activedocument.Shapes(ActiveShape).name

but it is not working

/Finn
 
H

Helmut Weber

Hi Finn,
easy with the name, kind of odd with the index:
Sub test9991()
Dim n As String 'Name
Dim i As Integer
n = Selection.ShapeRange.Name
For i = 1 To ActiveDocument.Shapes.Count
If ActiveDocument.Shapes(i).Name = n Then
MsgBox "Shape " & Chr(34) & n & Chr(34) & " is Shape " & i
Exit For
End If
Next
End Sub
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
F

Finn Petersen

Helmut Weber said:
Hi Finn,
easy with the name, kind of odd with the index:
Sub test9991()
Dim n As String 'Name
Dim i As Integer
n = Selection.ShapeRange.Name
For i = 1 To ActiveDocument.Shapes.Count
If ActiveDocument.Shapes(i).Name = n Then
MsgBox "Shape " & Chr(34) & n & Chr(34) & " is Shape " & i
Exit For
End If
Next
End Sub
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98

Thanks Helmut
It works perfect
/Finn
 

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