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

Help W Excel Mappoint VBA

This is a discussion on Help W Excel Mappoint VBA within the MapPoint Desktop Discussion forums, part of the Map Forums category; I'm a new developer to MP, and only OK w/VBA in excel. I'm trying to write an Excel UDF that ...

  1. #1
    Eric_j_wick is offline Junior Member White Belt
    Join Date
    Apr 2006
    Posts
    6

    Help W Excel Mappoint VBA

    I'm a new developer to MP, and only OK w/VBA in excel. I'm trying to write an Excel UDF that calculates the distance between two addresses. I've already been around the net, including here:

    http://www.dailydoseofexcel.com/inde...tions/&paged=2 (scroll down)

    I'm having trouble with getting the FindAddressResults method to work, though I can make FindResults work fine.

    I've beed so fristrated getting this to work, that I've abandon the UDF and am working with a simple plotting script from somewhere on the web. When I run it, I get the following message: "the parameter is incorrect"

    Here's my code:
    Code:
    Private Sub mapit()
    Dim oApp As MapPoint.Application
    Dim Objloc As MapPoint.FindResults
      Set oApp = CreateObject("MapPoint.Application.NA.11")
      oApp.Visible = True
      Set oBJMap = oApp.NewMap
     
      'From online instructions: object.FindAddressResults([Street], [City],_
            '[OtherCity], [Region], [PostalCode], [Country])
      '*************
      'Samples coppied from MS website
      '*** Set objLoc = objMap.FindAddressResults("1 Microsoft Way", "Redmond", "WA")(1)
      '****Set objloc = objApp.ActiveMap.FindAddressResults("One Microsoft Way", "Redmond", , "WA
      '******
      'My code that doesn't work -- I get "the parameter is incorrect" error
           Set Objloc = oBJMap.FindAddressResults("4724 Main Street", "Downers Grove", "IL")(1)
      '******************
      oBJMap.AddPushpin Objloc, "NAME"
      objMap.DataSets.ZoomTo
    End Sub

    Please help.

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

    FindAddressResults need 6 arguments, where some of them may be an empty string:

    Code:
    FindAddressResults(street, city, othercity, region, zip, country);
    I see only 3 in your example.

    BTW: What is the meaning of the extra parentesis '(1)' ?

  3. #3
    Eric_j_wick is offline Junior Member White Belt
    Join Date
    Apr 2006
    Posts
    6
    So I have tried it every logical way, ut it doesn't work for me. The code you see above is taken right from the MS website, but I can't make it work. I've tried the 6 arguments suggested and every other logical combination.

    Obviously I'm doing somthething wrong, but my code looks to me exactly like the code from the MS website. Very frustrating.

    Help.

    EW

  4. #4
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4
    Wilfried -- I think FindAddressResults actually returns a collection so the extra parentheses tells it to use the first item in the collection.

    Eric -- have you tried the samples in the Help File? Also, take a look at the series of MapPoint / Excel mini-tutorials in the newsletters.

    By the way, my name is also Eric and I live in Chicago and am a consultant and MapPoint programmer, we should get together for a beer sometime.

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

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

    Ok I do not know VB, but if the second parentasis is telling to use the first item in the collection, what happens if this item is NULL? Could that give an error ?

    Just do some guessing of course ...

  6. #6
    Eric_j_wick is offline Junior Member White Belt
    Join Date
    Apr 2006
    Posts
    6

    Still Frustrated

    Eric,

    Thanks for the post. Happy to buy the beer if you can help me solve this problem.

    I couldn't find FindAddressResults in Mappoint's Help, and I actually did go to through all of the web tutorials. In fact, when I cut and paste the code from the tutorials to Excel VBA, the ones with FindAddressResults fail to work. As I menioned above, FindResults seems to work for me. There is somethig with the syntax in FindAddressResults that I'm missing and it's driving me nuts.

    Please help.

    Cheers,

    Eric

  7. #7
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4
    Just a long shot, but are you possible using MapPoint 2000 or 2001? -- or is either version installed on the machine?

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

  8. #8
    Eric_j_wick is offline Junior Member White Belt
    Join Date
    Apr 2006
    Posts
    6

    Help with map point Excel VBA

    I'M using Mappoint North America 2004 and I can get the Findresults method to work just find. It's FindaAddressResults that is failing.

    Help

    EW

  9. #9
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4
    Did you try the example from the Help file?

    Sub FindAddressSearch()
    Dim objApp As New MapPoint.Application
    Dim objFindResults As MapPoint.FindResults

    'Set up application
    objApp.Visible = True
    objApp.UserControl = True

    'Output first result of find search
    Set objFindResults = objApp.ActiveMap.FindAddressResults("One Microsoft Way", "Redmond", , "WA", , geoCountryUnitedStates)
    MsgBox "The first item in the find list is: " _
    + objFindResults.Item(1).Name

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

  10. #10
    Eric_j_wick is offline Junior Member White Belt
    Join Date
    Apr 2006
    Posts
    6

    Example From Help fails

    I cut and paste your example directly into the Excel VBA and run the app.

    Mappoint kicks off and shows a map of the USA, but then the VBA gets an error "Cannot parse an addresssin the specified country". I tried substituting "United States", 244, and leaving hte country blank. No joy.

    Help!

    Cheers,

    Eric

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. mappoint and excel
    By mike_v in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 05-30-2006, 03:35 PM
  2. Excel & MapPoint
    By Dingo1 in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 12-12-2005, 08:14 PM
  3. Excel and MapPoint
    By Eric Frost in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 05-09-2005, 10:01 PM
  4. Mappoint & Excel
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 10-27-2004, 04:38 AM
  5. MPControl embedded in excel - excel loses functionality
    By ruyasan in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 05-20-2004, 04:41 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