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

closing Mappoint

This is a discussion on closing Mappoint within the MapPoint Desktop Discussion forums, part of the Map Forums category; Thanks to all of you out there who post and let newbies like me discover code to automate Mappoint. The ...

  1. #1
    rvalone is offline Junior Member White Belt
    Join Date
    Nov 2010
    Posts
    10

    closing Mappoint

    Thanks to all of you out there who post and let newbies like me discover code to automate Mappoint. The first macro below create a mappoint map with a number of pushpins on it from Excel and it works fine. The problem I fine is everytime I run the macro a new mappoint map is opened and after a while I've got a lot of maps opened. I searched web and forum looking for code to close mappoint each time I run the macro ( see sub routine to close Mappoint) which works fine if Mappoint is open, however if its not I get a error message ActiveX component can't create object. Any ideas as to what's happening and how to fix it.


    Private Sub submitMapChoice_Click2()
    Dim objMap As MapPoint.Map
    Dim objLoc As MapPoint.Location
    Dim objPushpin As MapPoint.Pushpin

    ' sub routine to close Mappoint
    Set oApp = GetObject(, "MapPoint.Application")
    oApp.ActiveMap.Saved = True
    oApp.Quit
    Set oPApp = Nothing

    Set oApp = CreateObject("MapPoint.Application.NA")
    Set objMap = oApp.NewMap
    nReadRow = 2
    Do While Sheets("MapData").Cells(nReadRow, 1) <> ""
    MyLat = Sheets("MapData").Cells(nReadRow, 1)
    MyLon = Sheets("MapData").Cells(nReadRow, 2)
    szname = Sheets("MapData").Cells(nReadRow, 4)
    Set objLoc = objMap.GetLocation(MyLat, MyLon, 0)
    Set objPushpin = objMap.AddPushpin(objLoc, szname)
    objPushpin.Note = Sheets("MapData").Cells(nReadRow, 4)
    objPushpin.BalloonState = geoDisplayName
    nReadRow = nReadRow + 1
    Loop
    oApp.Visible = True
    oApp.WindowState = geoWindowStateMaximize
    objMap.DataSets.ZoomTo
    objMap.DataSets(1).Name = "MarketPointe - LandTracker"
    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: closing Mappoint

    You need to keep a global variable that is the reference to your application object.
    Then re-use this, rather than creating a new application object in the click event handler.


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

  3. #3
    rvalone is offline Junior Member White Belt
    Join Date
    Nov 2010
    Posts
    10

    Re: closing Mappoint

    can you direct me to some sample code that would set the global variable and let me move back and forth between excel and mappoint without opening and closing mappoint?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Closing MapPoint
    By pepumarius in forum MapPoint Desktop Discussion
    Replies: 8
    Last Post: 08-19-2008, 10:24 AM
  2. MapPoint crashs after closing the application
    By Elbarto in forum MapPoint Desktop Discussion
    Replies: 12
    Last Post: 12-30-2006, 10:47 PM
  3. mapPoint 2006 activex control slow down form closing
    By bule in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 09-26-2006, 02:22 PM
  4. Disabling closing of MapPoint?
    By MD2000 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 05-09-2005, 05:57 PM
  5. Closing: MapPoint process stilll running
    By MD2000 in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 04-29-2005, 09:58 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