Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 3 of 3

VBA to get pushpin name in shapes

This is a discussion on VBA to get pushpin name in shapes within the Development forums, part of the MapPoint Desktop Discussion category; Hi, I have this code and I am not able to make it work. The code is suppose to export ...

  1. #1
    parefr is offline Junior Member White Belt
    Join Date
    Jan 2010
    Posts
    5

    VBA to get pushpin name in shapes

    Hi, I have this code and I am not able to make it work. The code is suppose to export the pushpin names from every shape in a map. The first part is ok (getting the shape name) but I always get stuck when I try to go trough the pushpin in that shape.

    Can someone help me with this?


    Code:
     
    Private Sub test()
    Dim objApp As MapPoint.Application
    Dim objMap As MapPoint.Map
    Dim objShape As MapPoint.Shape
    Dim objDataSet As MapPoint.DataSet
    Dim objDataSets As MapPoint.DataSets
    Dim objRecords As MapPoint.Recordset
    Dim test As Long
    Dim CountOfShapes As Integer
    Dim i As Long
     
    Set objMap = GetObject(, "Mappoint.Application.NA.17").ActiveMap
    CountOfShapes = objMap.Shapes.Count
     
    i = 1
    For Each objShape In objMap.Shapes
        Z = objShape.Name
    'Get the name of all the pushpins in the shape Z, the code dosn't work from that point
        For Each objPushpin In Z ' I know it's not Z that is suppose to be there but I have no clue what it should be
            A = objPushpin.Name
            Cells(i, 1) = Z
            Cells(i, 2) = A
            i = 1 + 1
        Next objPushpin
    Next objShape
    End Sub
    Last edited by parefr; 01-29-2010 at 11:57 AM.

  2. #2
    davidb is offline Senior Member Blue Belt
    Join Date
    Oct 2003
    Location
    London
    Posts
    290

    Re: VBA to get pushpin name in shapes

    Hi there. I'm assuming you have an active MP map with shapes that already have names and one or more pushpin sets (no other type of dataset). I think you then need to select each shape one by one and splurge out the pushpin names for that shape. Based on your code it would look something like (completely untested)...

    Code:
    Private Sub test()
    
    Dim objApp As MapPoint.Application
    Dim objMap As MapPoint.Map
    Dim objShape As MapPoint.Shape
    Dim objDataSet As MapPoint.DataSet
    Dim objDataSets As MapPoint.DataSets
    Dim objRecords As MapPoint.Recordset
    Dim test As Long
    Dim CountOfShapes As Integer
    Dim intRow As Long
     
    Set objMap = GetObject(, "Mappoint.whatever version.....").ActiveMap
    Set objDataSets = objMap.DataSets
    CountOfShapes = objMap.Shapes.Count
     intRow = 2
      For Each objShape In objMap.Shapes
       'actually select each shape one-by-one
        objShape.Select
        Z = objShape.Name
       
        'then go through each data set one-by-one
          For Each objDataSet In objDataSets
            Set objRecordSet = objDataSet.QueryShape(objShape)
            objRecordSet.MoveFirst
                 
                'then go through each record
                 Do While Not objRecordSet.EOF
                   Set objPin = objRecordSet.Pushpin
                   Cells(intRow, 1) = Z
                   Cells(intRow, 2) = objPin.Name
                   intRow = intRow + 1
                   objRecordSet.MoveNext
                 Loop
                
           Next
     
      Next objShape
    
    End Sub
    Hope that helps.

    rgds
    David
    UK mapping and map analysis services at www.broomanalysis.plus.com

  3. #3
    parefr is offline Junior Member White Belt
    Join Date
    Jan 2010
    Posts
    5

    Re: VBA to get pushpin name in shapes

    Thanks everything is working well.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. deleting shapes
    By bartj in forum MapPoint Desktop Discussion
    Replies: 6
    Last Post: 07-10-2008, 02:46 PM
  2. Getting Records within Shapes
    By MagiCat in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 02-21-2007, 02:47 PM
  3. Shapes behind roads?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 08-27-2003, 10:35 AM
  4. Using Shapes as Territories
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 08-01-2003, 10:14 AM
  5. Drawing shapes on the ocx
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 10-01-2002, 05:54 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127