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
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

How to look for specific word in mappoint direction

This is a discussion on How to look for specific word in mappoint direction within the MP2K Magazine Articles forums, part of the Map Forums category; Hi Everyone, I am trying to look for a specific word in mappoint direction such as " Check Timetable" in ...

  1. #1
    rodman is offline Junior Member Yellow Belt
    Join Date
    Sep 2010
    Posts
    19

    How to look for specific word in mappoint direction

    Hi Everyone,
    I am trying to look for a specific word in mappoint direction such as " Check Timetable" in direction pane in mappoint when I use the following code, after the word found then want to insert it in a cell. Anybody knows how?

    Dim oApp As MapPoint.Application

    Set oApp = CreateObject("MapPoint.Application.NA.17")
    oApp.Visible = True
    oApp.UserControl = True
    Set objMap = oApp.NewMap
    Set ObjRoute = objMap.ActiveRoute
    On Error Resume Next
    szZip1 = Worksheets("Mvan").Cells(5, 2)
    szZip2 = Worksheets("Mvan").Cells(6, 2)

    'Add route stops and calculate the route
    ObjRoute.Waypoints.Add objMap.FindResults(szZip1).Item(1)
    ObjRoute.Waypoints.Add objMap.FindResults(szZip2).Item(1)
    ObjRoute.Calculate
    End Sub

  2. #2
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60

    Re: How to look for specific word in mappoint direction

    Sorry, I was meaning to reply to your original thread but couldn't find it (probably because it is in a less-logical forum).
    I was thinking of trying to get something together for you and writing it up for Eric, but I simply haven't had the time.

    The Directions collection hangs off the Route object. You will need to iterate over this.
    For an example, look in the documentation under Routes, Directions, and Direction objects.
    Under the Instruction property on the Direction object, there's this sample:

    Code:
      Sub Get2ndDirectionInstruction()
    
      Dim objApp As New MapPoint.Application
      Dim objMap As MapPoint.Map
      Dim objRoute As MapPoint.Route
    
      'Set up the application
      Set objMap = objApp.ActiveMap
      Set objRoute = objMap.ActiveRoute
      objApp.Visible = True
      objApp.UserControl = True
    
      'Add route stops and calculate the route
      objRoute.Waypoints.Add objMap.FindResults("Seattle, WA").Item(1)
      objRoute.Waypoints.Add objMap.FindResults("Redmond, WA").Item(1)
      objRoute.Calculate
    
      'Output the text of the second direction
      MsgBox "The second direction is: " _
        + objRoute.Directions.Item(2).Instruction
    
      End Sub

    You will then need to look in your VBA docs to understand for loops and iteration. Use the Directions's Count property to find the upper bound - ie. iterate from 1 to Count.

    Then look in the VBA docs for string functions, and find out how to check for the inclusion of one string in another (instr$ rings a bell but it is a long time since I've used it). You may also want to handle case (convert all to lower case first, is a good way) and space padding (VBA has space trimming functions - Trim$ I think?).

    Hopefully this should get you pointed in the right direction. You're lucky the manuals are readily available and online.


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  3. #3
    rodman is offline Junior Member Yellow Belt
    Join Date
    Sep 2010
    Posts
    19

    Re: How to look for specific word in mappoint direction

    Thanks for responding. That's not what exactly I want. Maybe I didn't explain it very well. Let me have you look at this code first:

    Private Sub CommandButton1_Click()
    Dim oApp As MapPoint.Application

    Set oApp = CreateObject("MapPoint.Application.NA.17")
    oApp.Visible = True
    Set objMap = oApp.NewMap
    Set ObjRoute = objMap.ActiveRoute
    On Error Resume Next
    szZip1 = Worksheets("sheet1").Cells(5, 2)
    szZip2 = Worksheets("sheet1").Cells(6, 2)
    On Error Resume Next
    'Add route stops and calculate the route
    ObjRoute.Waypoints.Add objMap.FindResults(szZip1).Item(1)
    ObjRoute.Waypoints.Add objMap.FindResults(szZip2).Item(1)
    ObjRoute.Calculate

    Worksheets("sheet1").Cells(12, 2) = ObjRoute.Distance

    Dim objApp As MapPoint.Application

    ObjRoute.Clear
    objMap.Saved = True

    End Sub

    As you see when I put one zip code in cell 5,2 and one in cell 6,2 then when I click on command button I get result in mile for distance in cell 12,2. But when I try for example from zip 98101 to zip 98110 the result is 6 miles which is decieiving because you need to take ferry for this route plus 6 miles driving. So I need another code telling me this route required ferry or something like that and be inserted into one of the cells. I have noticed in the direction for such route when ferry needed it says *check timetable* so I figure if the code looks for such a word and once found, we could say "this route required ferry" and then we make it go to any cell . I hope it makes sense. Thanks
    Last edited by rodman; 09-24-2010 at 05:55 PM.

  4. #4
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60

    Re: How to look for specific word in mappoint direction

    Have you looked at what is stored in the Instruction properties of the Direction objects, yet?

    This holds the direction information you see displayed to the screen.


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  5. #5
    rodman is offline Junior Member Yellow Belt
    Join Date
    Sep 2010
    Posts
    19

    Re: How to look for specific word in mappoint direction

    Forgive me if I have to ask you this stupid question: how do I look? Do you mean to go help menu on Mappoint. If yes, I have already looked and I don't see anything would get me to what I need unless I'm not looking correctly.

  6. #6
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60

    Re: How to look for specific word in mappoint direction

    All of the programming interface (including the example I posted above) is listed in the Help Contents under "Programming Information". Try writing a simple program which creates a route that you know contains a ferry trip. Then print out the Instruction property values for all the Direction objects - what you do you see?


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  7. #7
    rodman is offline Junior Member Yellow Belt
    Join Date
    Sep 2010
    Posts
    19

    Re: How to look for specific word in mappoint direction

    Yes I have already been looking at the same area but I have not found anything for ferry whatsoever which is really strange everything but ferry. Let me understand this so if I map 98101 to 98110 which required ferry I get this instruction:

    Time Mile Instruction For Toward
    Summary: 5.9 miles (51 minutes)
    9:00 AM 0.0 Depart 98101 on Convention Pl (South) 131 yds
    9:00 AM 0.1 Road name changes to Union St 0.3 mi
    9:01 AM 0.4 Turn LEFT (South) onto 2nd Ave 0.3 mi
    9:02 AM 0.7 Turn RIGHT (West) onto Madison St 0.2 mi
    9:03 AM 0.9 Turn LEFT (South) onto Alaskan Way 0.2 mi
    9:03 AM 1.0 Turn RIGHT (West) onto Yesler Way 0.1 mi
    9:03 AM 1.2 Bear LEFT (West) onto Marion St 10 yds
    9:03 AM 1.2 *Check timetable* Take Seattle-Bainbridge Island Ferry (West)
    9:42 AM 1.2 Take Olympic Dr SE (North-West) 0.3 mi
    9:42 AM 1.4 Road name changes to SR-305 [Wa-305 NE] 2.9 mi
    9:46 AM 4.3 Turn LEFT (West) onto NE Koura Rd 1.0 mi
    9:49 AM 5.3 Turn LEFT (South) onto Mandus Olson Rd NE 0.5 mi
    9:51 AM 5.9 Arrive 98110

    But where do I find property values for this particular route? because all I see under programming information is prefixed examples. Am I missing something here?
    In the meantime I have a question for you: in your code above "objRoute.Directions.Item(2).Instruction" if I want to see all items in direction what do I enter in parentheses instead of 2 ? I tried " item.(1,2,3,4,5,6,7,8,9,10) " it didn't work!
    Last edited by rodman; 09-29-2010 at 11:52 PM.

  8. #8
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60

    Re: How to look for specific word in mappoint direction

    Yes put a number in the Item () brackets. Use the Directions.Count property to find out how many directions there are.

    Note that there are two levels of directions. You will probably need a nested loop to check both levels. eg. as well as myRoute.Directions.Item(X).Instruction, also look at myRoute.Directions.Item(X).Directions.Item(Y).Inst ruction


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  9. #9
    rodman is offline Junior Member Yellow Belt
    Join Date
    Sep 2010
    Posts
    19

    Re: How to look for specific word in mappoint direction

    But my question is if I put a single number in the bracket I only see one line: for example item(1) only shows the first line of direction, item(2) only shows the second line of direction and etc. but I need something that shows me all lines of direction. Do I make sense? Something like item(all) if such thing exists. Because if I find a code for that , I can figure it out the rest. Since there is nothing for "Ferry", I am trying to solve this problem in different way and as soon as I know how to show the complete direction for the route not just one line of direction, then I will tell you what I am trying to accomplish. Thanks

  10. #10
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60

    Re: How to look for specific word in mappoint direction

    Which is why you need the loop. I think you need to read up on some basic programming skills and constructs first before taking this project any further.


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Pasting a Mappoint Legend into MS Word 2003
    By Eric B in forum Wish List
    Replies: 0
    Last Post: 08-18-2005, 04:44 PM
  2. Using MapPoint from Word, Access and Excel
    By Anonymous in forum MP2K Magazine Articles
    Replies: 4
    Last Post: 11-26-2004, 08:56 PM
  3. Cut and Paste Problem with Word 2003 and MapPoint 2004
    By brubli in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 10-21-2004, 05:26 PM
  4. Mail Merge using MapPoint 2004 and Word 2003
    By fibble9 in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 04-14-2004, 05:29 PM
  5. When working with mappoint and coping to word how ....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 06-28-2002, 09:20 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 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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127