Selecting Shape Based on Name

Anonymous
09-03-2004, 03:46 AM
I have some code where I want to select a shape based on its name

Dim objShape As MapPoint.Shape
Dim strName As String

strName = "NA123456"

objShape = objMap.Shapes.Item(strName)

Basically something like that, however everytime I run it I get the rather irratating Mappoint has encountered a problem and needs to close window.

If I do

objShape = objMap.Shapes.Item(1)

It works fine

The help files clearly state that you can select a shape based on its name, and all the shapes have been named properly.

Has anyone else encountered a similar problem or has any ideas as to what i'm doing wrong

John Meyer
09-07-2004, 10:01 AM
Not all shapes have a name property (like a geoline for example). Here is a basic sample that might help. Create a shape (Rectangle,Oval or Circle) and name it "MyShape"

Dim objshape As MapPoint.Shape
For Each objshape In MappointControl1.ActiveMap.Shapes

Select Case objshape.Type
Case 1 ' An AutoShapeType (Rectangle,Oval or Circle)
If objshape.Name = "MyShape" Then
MsgBox "Do Something"
End If
End Select
Next

 
Web mp2kmag.com
mapforums.com