I've been putting together code snippets that seem to completely solve my problem of determining which of 56,000 records in Excel are within approximately 10 shapes. I think I have everything working except that I'm getting the following error:
Error 438: Object doesn't support this property or method
in the line:
If I get rid of the line, it works completely and outputs the right number of shapes but I need to move the shapes to the other DataSet. Can anyone tell me what I'm doing wrong?
Here's the full code:
Code:Sub QueryRecordsInShapes() Dim objApp As New MapPoint.Application Dim objMap As MapPoint.Map Dim objDataSet As MapPoint.DataSet Dim objDataInShapes As MapPoint.DataSet Dim objRecords As MapPoint.Recordset Dim objshape As MapPoint.Shape Dim lngCount As Long 'Set up application and objects to use objApp.Visible = True objApp.UserControl = True Set objMap = objApp.OpenMap("c:\toters\toters.ptm") lngCount = 0 'Let user create a data map Set objDataSet = objApp.ActiveMap.DataSets.ShowImportWizard 'Create New Dataset Set objDataInShapes = objApp.ActiveMap.DataSets.AddPushpinSet("InShapes") 'iterate through all shapes For Each objshape In objMap.Shapes 'Find records in shape objshape.Select Set objRecords = objDataSet.QueryShape(objshape) objRecords.MoveFirst Do While Not objRecords.EOF lngCount = lngCount + 1 'Getting Error objRecords.Pushpin.MoveTo (objDataInShapes) objRecords.MoveNext Loop Next MsgBox "Number of records in shapes: " & lngCount End Sub