DeepBlue
05-04-2007, 04:52 PM
I have some experience in Excel VBA but am still fairly new. This is the first time I have tried to automate MapPoint with it though. What I want to do is create a Freeform in MapPoint with the 'points' retrieved from the excel workbook.
Lets say that Latitudes were in the A column in Sheet1 and Longitudes were in the B column of Sheet1. I looked up the sample code for polyline and tried playing around with what I need to set the objLoc(x) to, but could not figure out anything that works.
I want to replace the ? with something that will get the latitude and longitude from the excel spreadsheet, and then draw the shape in MapPoint.
************************************************** ****
Sub AddPolylineToMap()
Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objLoc(1 To 3) As MapPoint.Location
'Set up the application
Set objMap = objApp.ActiveMap
objApp.Visible = True
objApp.UserControl = True
'Get three locations and zoom in
Set objLoc(1) = ?
Set objLoc(2) = ?
Set objLoc(3) = ?
Set objMap.Location = objLoc(1)
'Create a polyline by connecting these locations
objMap.Shapes.AddPolyline objLoc
End Sub
************************************************** ****
Thanks for the help.
Lets say that Latitudes were in the A column in Sheet1 and Longitudes were in the B column of Sheet1. I looked up the sample code for polyline and tried playing around with what I need to set the objLoc(x) to, but could not figure out anything that works.
I want to replace the ? with something that will get the latitude and longitude from the excel spreadsheet, and then draw the shape in MapPoint.
************************************************** ****
Sub AddPolylineToMap()
Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objLoc(1 To 3) As MapPoint.Location
'Set up the application
Set objMap = objApp.ActiveMap
objApp.Visible = True
objApp.UserControl = True
'Get three locations and zoom in
Set objLoc(1) = ?
Set objLoc(2) = ?
Set objLoc(3) = ?
Set objMap.Location = objLoc(1)
'Create a polyline by connecting these locations
objMap.Shapes.AddPolyline objLoc
End Sub
************************************************** ****
Thanks for the help.