PDA

View Full Version : Vba Help - Want to change mypushpins title to another name and define the colour/type of pushpins



antthorne
09-19-2013, 05:07 AM
Hi

I found a version of the following code from google search and have modified slightly to achieve some of my goals.



Sub AddWaypoints()
Set oAPP = CreateObject("MapPoint.Application")
Dim row As Integer
Dim name As String
Dim oMap As MapPoint.MAP
Set oMap = GetObject(, "MapPoint.Application").ActiveMap
oAPP.Visible = True
oAPP.UserControl = True
row = 2
'Do until column B is blank
Do While Cells(row, 2) <> ""
'szzip1 postcodes in column A
szzip1 = Cells(row, 1).Value
'name in column b
name = Cells(row, 2).Value
'adds pushpin
oMap.AddPushpin oMap.FindResults(szzip1).Item(1), name
'adds name to pushpin
oMap.FindPushpin(name).BalloonState = geoDisplayName
row = row + 1
Loop
End Sub


After all the pushpins have been created I would like the vba to change the Title of the Pushpin set to change to 'Vision Deliveries', I would also like to change the colour and type to the ones defined in the vba.

The reason for this is that I want to add 4 sets of data and would like to see them on the same map.

Hope this makes sense

Any help would be very much appreciated.

Thanks
Antthorne

Eric Frost
09-19-2013, 06:27 AM
Antthorne -- welcome to the forums! I hope we can help!


After all the pushpins have been created I would like the vba to change the Title of the Pushpin set to change to 'Vision Deliveries'

This will change the first dataset's name: oMap.Datasets(1).Name = "Vision Deliveries"


I would also like to change the colour and type to the ones defined in the vba.

To change the symbol is also quite easy: oMap.Datasets(1).Symbol = oMap.Symbols("small red circle")

Hope this helps! Let us know how it goes! Please feel free to post back here with further questions.

Eric

antthorne
09-19-2013, 06:41 AM
Hi Eric

Thanks you for the welcome and your very quick response.

Works brilliantly.

Thanks
Ant

Eric Frost
09-20-2013, 08:23 AM
My pleasure, please feel free to post anytime and good luck with your project!