Determine the index number of the current shape
Author Message
Determine the index number of the current shape

Hi,
Could someone tell me how to determine the index number or the name of
the current shape (Text Frame)?

Thanks.
Wu Hailong

Sat, 08 Nov 2003 11:10:47 GMT
Determine the index number of the current shape

To get the shape's name:  MsgBox Selection.ShapeRange(1).Name

To get its index number:  Weeeeell, first you probably should read
http://www.mvps.org/word/FAQs/MacrosVBA/GetIndexNoOfPara.htm to get
the full pep talk on why you probably *don't* really need the index
number.  Then if you still think you do:

Dim sh As Shape, i As Integer
For Each sh In ActiveDocument.Shapes
i = i + 1
If Selection.InRange(sh.TextFrame.TextRange) Then
MsgBox "This is shape number " & i
Exit For
End If
Next sh

------ WWW: http://www.speakeasy.org/~mtangard ----------------------
------------- "Life is nothing if you aren't obsessed." --John Waters
---------------------------------------------------------------------

Quote:

> Hi,
>     Could someone tell me how to determine the index number or the name of
> the current shape (Text Frame)?

> Thanks.
> Wu Hailong

Mon, 10 Nov 2003 18:47:59 GMT
Determine the index number of the current shape

To get the shape's name:  MsgBox Selection.ShapeRange(1).Name

To get its index number:  Weeeeell, first you probably should read
http://www.mvps.org/word/FAQs/MacrosVBA/GetIndexNoOfPara.htm to get
the full pep talk on why you probably *don't* really need the index
number.  Then if you still think you do:

Dim sh As Shape, i As Integer
For Each sh In ActiveDocument.Shapes
i = i + 1
If Selection.InRange(sh.TextFrame.TextRange) Then
MsgBox "This is shape number " & i
Exit For
End If
Next sh

------ WWW: http://www.speakeasy.org/~mtangard ----------------------
------------- "Life is nothing if you aren't obsessed." --John Waters
---------------------------------------------------------------------

Quote:

> Hi,
>     Could someone tell me how to determine the index number or the name of
> the current shape (Text Frame)?

> Thanks.
> Wu Hailong

Mon, 10 Nov 2003 18:47:59 GMT
Determine the index number of the current shape
I agree about the index numbers. But the StoryRanges question gets pretty
complicated, actually, due to some limitations with the StoryRanges object--it
doesn't come close to iterating every StoryRange in a document. Have a look at
the "StoryRange" thread beginning on May 23.
Quote:
-----Original Message-----

To get the shape's name:  MsgBox Selection.ShapeRange(1).Name

To get its index number:  Weeeeell, first you probably should read
http://www.mvps.org/word/FAQs/MacrosVBA/GetIndexNoOfPara.htm to get
the full pep talk on why you probably *don't* really need the index
number.  Then if you still think you do:

Dim sh As Shape, i As Integer
For Each sh In ActiveDocument.Shapes
i = i + 1
If Selection.InRange(sh.TextFrame.TextRange) Then
MsgBox "This is shape number " & i
Exit For
End If
Next sh

------ WWW: http://www.speakeasy.org/~mtangard ----------------------
------------- "Life is nothing if you aren't obsessed." --John Waters
---------------------------------------------------------------------

> Hi,
>     Could someone tell me how to determine the index number or the name of
> the current shape (Text Frame)?

> Thanks.
> Wu Hailong
.

Mon, 10 Nov 2003 23:35:03 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages