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

Trip duration

This is a discussion on Trip duration within the Development forums, part of the MapPoint Desktop Discussion category; I have an Excel user defined function to return the round trip distance between three way points (the start and ...

  1. #1
    trebormac is offline Junior Member White Belt
    Join Date
    Jan 2008
    Posts
    8

    Question Trip duration

    I have an Excel user defined function to return the round trip distance between three way points (the start and end waypoints are the same address). I know Mappoint will report a trip duration in hours and minutes once the "get directions" icon is involked. Is there a way to return the trip duration programmatically using VBA in Excel. I have searched through the Mappoint Object Model but don't find any memebers that would return trip duration.

    Thanks for any help!

    Trebormac

  2. #2
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: Trip duration

    Look some more. I know there is.... I have used it

    Take a look at the TripTime Property of the Route Object.

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  3. #3
    trebormac is offline Junior Member White Belt
    Join Date
    Jan 2008
    Posts
    8

    Re: Trip duration

    Thanks Eric,

    I did dig a little deeper and found "Driving Time" and "Trip Time", both members of the Route Class....I used the driving time method. With assistance from the MapPoint Help File I was able to create the VBA code I needed.

    Fot those interested I have attached the code as a text file. This is in the form of a user defined function in Excel, where I need to compute the driving time from a fixed location (address) to several dozen separate locations. Hence I hard coded the starting point in the code. This of course can be modified if there is no fixed starting point by using multiple input parameters in the function call, e.g., sAddress2, sAddress3, etc. and adding lines of code for each objRoute.Waypoint.FindResults(sAddress2...)

    The separate location addresses are in cells in a column. Invoke the function in a cell adjacent to the column containing the separate addresses, point it to the first address and hit OK. Then copy it down the column. If there a lot of addresses it may take some time to calculate.

    Thanks again,

    Trebormac
    Attached Files Attached Files

  4. #4
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: Trip duration

    Very cool, thanks for sharing the code. I am also posting the code in here in case anyone has trouble getting to the attachment.

    Code:
    Option Explicit
    
    Dim oApp As MapPoint.Application
    
    Function GetDuration(sAddress1 As String)
      Dim objMap As Map
      Dim objRoute As Route
    
      If oApp Is Nothing Then
          Set oApp = CreateObject("MapPoint.Application")
      End If
    
      oApp.Visible = False
      Set objMap = oApp.NewMap
      Set objRoute = objMap.ActiveRoute
    
      'Add route stop and calculate the route
      objRoute.Waypoints.Add objMap.FindResults("69 West Washington Street, Chicago, IL 60606").Item(1)
      objRoute.Waypoints.Add objMap.FindResults(sAddress1).Item(1)
      objRoute.Calculate
    
      GetDuration = objRoute.DrivingTime / geoOneMinute
    
      objMap.Saved = True
    
    End Function
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Merge routes/trips into one long trip
    By TenOC in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 05-21-2006, 11:48 AM
  2. automate stop duration and multiple routes
    By samlinc in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-22-2006, 10:44 AM
  3. Using Mappoint 2002 European edition for planning a USA-trip
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 09-21-2003, 06:42 AM
  4. Trip Planning
    By zylogue in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 03-07-2003, 07:30 PM
  5. Trip Standards: I'm thinking about purchasing MapP....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 12-17-2001, 12:35 PM

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