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 4 of 4

Adding Lat/long to polyline from excel

This is a discussion on Adding Lat/long to polyline from excel within the MapPoint Desktop Discussion forums, part of the Map Forums category; I have some experience in Excel VBA but am still fairly new. This is the first time I have tried ...

  1. #1
    DeepBlue is offline Junior Member White Belt
    Join Date
    May 2007
    Posts
    2

    Adding Lat/long to polyline from excel

    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.

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Adding Lat/long to polyline from excel

    Hi,

    You dont tell what exacly is not working. I assume you dont have a polyline. If that is the case I should start to check if the Location objects are correct. You can find this out by putting a pushpin on these locations.

  3. #3
    DeepBlue is offline Junior Member White Belt
    Join Date
    May 2007
    Posts
    2

    Re: Adding Lat/long to polyline from excel

    I have tried a few different things. For example, if I put the latitude and longitude in cells A1:A3 in the form Lat,Long and then try this for the code:

    Set objLoc(1) = Worksheets("sheet1").Range("A1")
    Set objLoc(2) = Worksheets("sheet1").Range("A2")
    Set objLoc(3) = Worksheets("sheet1").Range("A3")

    I get a "Run-time error ' 13': Type mismatch" error.

    I need to figure out what I need to set the objLoc(X) equal to so that it places the 'points' of the polyline at the locations from the excel spreadsheet.

  4. #4
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478

    Re: Adding Lat/long to polyline from excel

    can you show the format you are using for the lat/long?
    Like Wilfried said, try putting pushpins on the map first with code to verify you are passing the lat/long correctly.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Adding Excel Data as Pushpins
    By rosshood10 in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 08-31-2006, 12:25 PM
  2. Adding Pushpins from Excel 2003
    By Marktherob in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 02-07-2006, 06:13 PM
  3. Adding a PushPin from a Long/Lat position
    By zadic in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 10-06-2005, 01:33 PM
  4. Adding pushpins by lat/long or address using MPC in MSAccess
    By GM in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 11-01-2004, 01:00 PM
  5. in adding vendors in the excel side to be linked t....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-14-2001, 10:18 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