I am working on the following code to select pushpins graphically. I prefer not to send the data to Excel. If someone sees what's wrong with my code, I would appreciate the correction. The number of pushpins selected is always all of the pushpins on the map.
This is the code:
Private Sub mnuSelectRectangle_Click()
Dim intShapes As Integer
Dim longHeight As Long
Dim longWidth As Long
Dim longTop As Long
Dim longLeft As Long
Set objMap = MappointControl1.ActiveMap
longHeight = objMap.SelectedArea.Height
longWidth = objMap.SelectedArea.Width
longTop = objMap.SelectedArea.Top
longLeft = objMap.SelectedArea.Left
objMap.SelectedArea.SelectArea longTop, longLeft, longWidth, longHeight
Set objLoc = objMap.SelectedArea.Location
If longHeight = 0 Or longWidth = 0 Or longTop = 0 Or longLeft = 0 Then
MsgBox "Nothing selected. "
Exit Sub
End If
Set objShape = objMap.Shapes.AddShape(geoShapeRectangle, objLoc, CDbl(longWidth), CDbl(longHeight))
objShape.Select
MsgBox "The type of shape selected is " + CStr(objMap.Shapes.Item(1).Type)
Set objDataSet = objMap.DataSets.Item(2)
If objShape Is Nothing Then
MsgBox "objShape got lost"
End If
Set objRecordset = objDataSet.QueryShape(objShape)
' Loop over records and place the captured pushpins in a list box
objRecordset.MoveFirst
intShapes = 0
Do While Not objRecordset.EOF
frmSelectAccounts.lstAccounts.AddItem objRecordset.Pushpin.Name
objRecordset.MoveNext
intShapes = intShapes + 1
Loop
MsgBox "Number of records in shape: " + CStr(intShapes)
frmSelectAccounts.Show
End Sub