Community of VE/MapPoint Users and Developers
This is a discussion on Mappoint 2k and boundaries within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Is there any way to combine seperate maps with seperate yellow boundaries (areas to avoid) into one map without having ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Mappoint 2k and boundaries Thanks to anyone who can help me with this! bwinkeler@scholasticbookfairs .com |
| |||
|
Assuming you have access to some Microsoft Office product: This is not elegant, but will work in Word, Excel or Access in Office XP or 2003. I am not sure about 2000 because this uses the Application.FileDialog box which was not accessible in earlier Office versions. If you are a VBA Wiz then skip this and go on to the code, otherwise: In Word or Excel you will need to go Tools > Macro > Visual Basic Editor and insert a module. Copy and paste the code into the module. From the visual basic editor window, go to Tools > References and in the dialog box that pops up, check the box next to Microsoft MapPoint 9.0 Object Library (or whatever your version is). Save the module. Run the module by pressing F5 while the Visual Basic Editor is the active window. The same basic stuff will work in Visual Basic, with the exception of the FileDialog, you will need to replace it with the CommonDialog control or some other way of getting the file paths and names. Code: Private Sub CopyShapes()
'general variables
Dim srcFile As String
Dim targFile As String
Dim selItem As Variant
' Dim mpYellow As Long
'mappoint variables
Dim MPApp1 As MapPoint.Application
Dim MPApp2 As MapPoint.Application
Dim MPMap1 As MapPoint.Map
Dim MPMap2 As MapPoint.Map
Dim MPShape As MapPoint.Shape
'application variables
Dim FD As FileDialog
' mpYellow = &HFFFF&
'set up file dialog and get source file name
Set FD = Application.FileDialog(msoFileDialogFilePicker)
FD.AllowMultiSelect = False
FD.Filters.Clear
FD.Filters.Add "MapPoint Files", "*.ptm"
'select target file
With FD
.Title = "Select the file to which you want to copy:"
If .Show = -1 Then
For Each selItem In FD.SelectedItems
targFile = selItem
Next
Else
'user pressed cancel, no file to process so exit
Exit Sub
End If
End With
'initialize target map
Set MPApp1 = CreateObject("Mappoint.Application")
Set MPMap1 = MPApp1.OpenMap(targFile, False)
'you might want to put this at the end
'the map spins and moves around a lot as the
'copy work is being done
'disadvantage to moving to the end is if an error occurs
'MapPoint will run in the background unless you kill it in the
'task manager
MPApp1.Visible = True
MPApp1.UserControl = True
Application.Activate
'select source files
With FD
.AllowMultiSelect = True
.Title = "Copy shapes from:"
If .Show = -1 Then
For Each selItem In FD.SelectedItems
srcFile = selItem
Set MPApp2 = CreateObject("Mappoint.Application")
Set MPMap2 = MPApp2.OpenMap(srcFile, True)
MPApp2.Visible = True
MPApp2.UserControl = True
'this part will make you dizzy if you choose to
'make the applications visible
For Each MPShape In MPMap2.Shapes
If MPShape.Type = geoFreeform Or geoAutoShape Then
MPShape.Copy
MPMap1.Paste
End If
Next
Next
Else
'user pressed cancel, no file to process so exit
Exit Sub
End If
End With
'clean up
Set MPApp1 = Nothing
Set MPApp2 = Nothing
Set MPMap1 = Nothing
Set MPMap2 = Nothing
Set MPShape = Nothing
Set FD = Nothing
End Sub
|
| |||
| Thanks!....but
Here is alittle more info. We are using Windows 2000 pro, office 2000, and mappoint 2002 and a program called Direct Route from Appian Logistics. Will your above code work in this setup? I can get all the way to save the module and press f5 to run the module and a macro box pops up. I don't know what to do here and how do I get this to tie into mappoint 2002 to copy my boundaries? Thanks again for your help! bwinkeler@scholasticbookfairs.com |
| |||
|
Sorry, I left a few steps out and made a mistake. Change the Private to Public in the first line: Code: Public Sub CopyShapes() I have this as an add-in that you can run directly from MapPoint so that you don't have to open and close files. I just can't guarantee that it won't conflict with something else you are running. Running the macro takes an extra few steps, but should work pretty reliably. Now, when you have made the above change and saved the file, either press F5 or select run macro. You should see CopyShapes as an available macro. This is where things may not work with Office 2000. Run it and you should get a dialog box prompting you to select the file to which you want to copy the shapes. (I can't remember if Office 2000 supports the FileDialog objectj or if 2002/XP was the version it became developer-friendly). This is the destination file. Once you have selected the destination file, you will receive a prompt to select the source files. You may select more than one file as long as all the files you select reside in the same directory. So you might select AllZones as a newly created, blank map. You might then select Zone1, Zone2, and Zone3 as the source maps. The macro will copy all shapes that are freeform or autoshapes from Zone1, Zone2 and Zone3 to AllZones. All of the maps will stay open so that you can make sure that everything is copied correctly. If the above works and you want to specify just boundaries filled with yellow, you need to remove the apostrophe before mpYellow = &HFFFF& and change the line Code: If MPShape.Type = geoFreeform Or geoAutoShape Then Code: If MPShape.Fill.ForeColor = mpYellow And (MPShape.Type = geoFreeform Or geoAutoShape) Then |
| |||
| Help us Martel
Please send me an email address so I can send you our phone # here at Scholastic Book Fairs and we can talk while I go thru this step-by-step. We can't get your code to work! Thanks bwinkeler@scholasticbookfairs.com |
| |||
|
You should receive a link by e-mail with some instructions on how to add and test the add-in. See if it will run for you. If you have problems (you may receive some error like "Cannot find COMCTL32.dll" or "Wrong version COMCTL32.ocx" or something along those lines) contact me through e-mail and I will use a different version. I was trying to keep the file small. Nothing like version compatibility issues |
![]() |
| Tags |
| boundaries, mappoint |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Territory Boundaries | Anonymous | MapPoint 2006/2009 Discussion | 3 | 05-20-2004 05:48 PM |
| Showing all MSA boundaries on USA map | Anonymous | MapPoint 2006/2009 Discussion | 0 | 05-18-2003 05:51 PM |
| MapPoint 2003 and census 2000 tract boundaries | Anonymous | MapPoint 2006/2009 Discussion | 2 | 04-20-2003 07:03 AM |
| Importing 2000 Census boundaries into MapPoint | Anonymous | MapPoint 2006/2009 Discussion | 5 | 12-13-2002 06:36 PM |
| Will MapPoint include UK political boundaries, par.... | Anonymous | MapPoint 2006/2009 Discussion | 1 | 07-26-2001 08:44 AM |