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

Using MapPoint function from EXCEL VBA

This is a discussion on Using MapPoint function from EXCEL VBA within the MapPoint Desktop Discussion forums, part of the Map Forums category; I have this code in an excel file; the idea being to read two postcodes from cells A1 and B1, ...

  1. #1
    Jonboy is offline Junior Member White Belt
    Join Date
    Apr 2005
    Posts
    5

    Using MapPoint function from EXCEL VBA

    I have this code in an excel file; the idea being to read two postcodes from cells A1 and B1, and return the distance between them to Cell C1.
    I think the code is ok, but when I run it it says "User-Defined type not defined" and highlights the second line.

    Do I need to set up a specific tools>reference in Excel VBA first?

    Pretty please?!
    ______________

    Sub ShowDistance()
    Dim objApp As New MapPoint.Application
    Dim objMap As MapPoint.Map
    Dim objLocOne As MapPoint.Location
    Dim objLocTwo As MapPoint.Location

    Dim LocOne, LocTwo As String
    Dim Distance As Long

    Set objMap = objApp.ActiveMap

    LocOne = Cells(1, 1)
    LocTwo = Cells(1, 2)

    Set objLocOne = objMap.FindResults(LocOne).Item(1)
    Set objLocTwo = objMap.FindResults(LocTwo).Item(1)


    'Show the distance

    Distance = objMap.Distance(objLocOne, objLocTwo)

    Cells(1, 3) = Distance

    End Sub

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

    I wrote a tutorial related to this earlier this afternoon which I plan to publish tomorrow --
    http://www.mp2kmag.com/update/mappoi...er/2005-04-26/

    I think the answer to your question is actually in the Part I of the tutorials.

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

  3. #3
    Jonboy is offline Junior Member White Belt
    Join Date
    Apr 2005
    Posts
    5

    woohoo

    Got it working now, thanks Erik.
    Batch files here I come.

    Looking forward to part IV (which hopefully will include "fuzzy" address searches *cough* )

  4. #4
    JuL
    JuL is offline Junior Member White Belt
    Join Date
    Jul 2007
    Posts
    1

    Re: Using MapPoint function from EXCEL VBA

    I've just tried the code provided in the tutorial part III, but vba keeps on returning the same error message (Run-time error '429': ActiveX component can't create object ...) I'm running Excel 2003 and MapPoint 2004. Is there something I'm missing here?

    Thanks for your help!

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

    Re: Using MapPoint function from EXCEL VBA

    Check the reference under Tools References, it should not be the ActiveX control.

    Also, you might try doing this at the command line mappoint.exe /register

    Eric

  6. #6
    nimeshparikh is offline Junior Member White Belt
    Join Date
    Apr 2009
    Posts
    2

    Re: Using MapPoint function from EXCEL VBA

    Hi Eric,
    I have tried all the above steps, and also gone through the first tutorial in detail. I still receive the error:
    (Run-time error '429': ActiveX component can't create object ...)

    Not sure what is going wrong. I am using Office 2007 on Vista home, and using the trial version of MapPoint.
    Thanks.

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

    Re: Using MapPoint function from EXCEL VBA

    What version of MapPoint? I wonder if it is the MapPoint 2009 trial, if it hangs asking for the Activation code.

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

  8. #8
    nimeshparikh is offline Junior Member White Belt
    Join Date
    Apr 2009
    Posts
    2

    Re: Using MapPoint function from EXCEL VBA

    Eric,
    I figured, it was about EU versus NA, and 16 versus 11. Thanks. I now need to fetch distances for multiple origin-destination pairs. Where can I find some sample code for the same?
    Do I need to worry about closing and opening MapPoint for each 'fetch'? Or would the application handle 4-5000 distances without crashing?

    Thanks for your help.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need Help using the SUM function for County
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 04-08-2005, 11:48 PM
  2. Correlation between Mappoint FIND function and MPC???
    By GM in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 11-02-2004, 03:40 PM
  3. Problems with ShowFindDialog function in C++
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 10-06-2003, 05:13 AM
  4. Fix DistanceTo function
    By PC in forum Wish List
    Replies: 1
    Last Post: 03-21-2003, 06:35 AM
  5. Mappoint 2002 application provides the function th....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 12-20-2001, 10:48 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