PDA

View Full Version : obj.MoveTo / abjMap.AddPushpin issue



burnin240sx
11-15-2007, 10:54 AM
I am trying to get mappoint to make push pins for a list of sites and move them to a pushpin set called FEs.
this code creates the pushpins but craps on it self with runtime error '13' when i get to "objMap.AddPushpin objPin."

if i comment out "Dim objPin As MapPoint.Pushpin" then it gives me a error of "object doesn't suppot this property type or method" when i get to line "objPin.MoveTo objMap.DataSets.Item("FEs")"

I think that i'm creating the pushPin using the wrong method. but I don't know any other way.
any idea's?


Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objPin As MapPoint.Pushpin
'Set up the application
Set objMap = objApp.ActiveMap
objApp.Visible = True
objApp.UserControl = True
objMap.DataSets.AddPushpinSet "FEs"
'start for loop
For f = 0 To 21
' build fe pushppins
If Len(Worksheets("Sheet2").Cells(2 + f, 1)) > 0 Then
Set objPin = _
objMap.FindAddressResults( _
Worksheets("Sheet2").Cells(2 + f, 2), _
Worksheets("Sheet2").Cells(2 + f, 3), _
Worksheets("Sheet2").Cells(2 + f, 4), _
Worksheets("Sheet2").Cells(2 + f, 5))(1)

objMap.AddPushpin objPin, _
Worksheets("Sheet2").Cells(2 + f, 1)

objPin.MoveTo objMap.DataSets.Item("FEs")


End If
objPin.MoveTo objMap.DataSets.Item("FEs")
Next

Wilfried
11-16-2007, 12:49 PM
Hi,

You give a PushPin object as first argument to the AddPushPin method. This is wrong, you have to create first a Location object and the Location object has to be the first argument for the AddPushPin method.

burnin240sx
11-16-2007, 12:59 PM
i have switched up my code and i have got this to work
but now i'm trying to figure out how to give the push pin a name. right now it uses the address as the name.

Private Sub CommandButton1_Click()
Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim feLoc As MapPoint.Pushpin
Dim siteLoc As MapPoint.Pushpin

'Set up the application
Set objMap = objApp.ActiveMap
objApp.Visible = True
objApp.UserControl = True
objMap.DataSets.AddPushpinSet "FEs"
'start for loop
For f = 0 To 21
' build fe pushppins
If Len(Worksheets("Sheet2").Cells(2 + f, 1)) > 0 Then
Set feLoc = objMap.AddPushpin( _
objMap.FindAddressResults( _
Worksheets("Sheet2").Cells(2 + f, 2), _
Worksheets("Sheet2").Cells(2 + f, 3), _
Worksheets("Sheet2").Cells(2 + f, 4), _
Worksheets("Sheet2").Cells(2 + f, 5))(1))
feLoc.MoveTo objMap.DataSets.Item("FEs")
End If
Next