Community of VE/MapPoint Users and Developers
This is a discussion on Manipulating multiple maps in Excel within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I have a project where I have an Excel workbook with several sheets. Currently each sheet has a map embeded ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Manipulating multiple maps in Excel Method 1) When I try to loop through the sheets currently and link to the named range holding the address it places all of the pushpins on the map embeded on the first worksheet. I can not find a collection of maps to reference so that I can be sure I am getting the correct one. Method 2) My other thought, which I would prefer due to the resources used by the above example, is to have one embeded map and just move it to the active sheet when you click on the tab for that sheet. Once the map is moved to the active sheet I can then link to the correct data on that sheet. The problem here is I can not get the embeded map to move from one sheet to another using VBA. Code for method 1: Code: Public Sub MapIt(ws As worksheet, rcsutid as string)
Dim oMap As MapPoint.Map
Dim objPin As MapPoint.Pushpin
Dim szconn As String
Dim oDS As MapPoint.DataSet
Dim obj As OLEObject
Dim lRangeValues(1 To 3) As Variant
Dim zRangeNames(1 To 3) As String
Dim RS As MapPoint.Recordset
Dim High As Integer
Dim oDM As MapPoint.DataMap
On Error GoTo ErrorHandler
'make map interactive
ws.OLEObjects(1).Activate
'Get map
Set oMap = GetObject(, "MapPoint.Application").ActiveMap
'Clean out old datasets
For Each oDS In oMap.DataSets
oDS.Delete
Next
'Create new datasets
With oMap.DataSets
szconn = ActiveWorkbook.Path & "\JI_Dealer_Business_Plan.xls!" & ws.Name & "!location"
Set oDS = .ImportData(szconn, , geoCountryUnitedStates, , geoImportExcelNamedRange)
oDS.DisplayPushpinMap
Set RS = oDS.QueryAllRecords
RS.MoveFirst
Set objPin = RS.Pushpin
objPin.Location.Goto
oMap.ZoomIn
objPin.Symbol = 291
oDS.Name = rcustid & "Dealer Location"
szconn = ActiveWorkbook.Path & "\JI_Dealer_Business_Plan.xls!" & ws.Name & "!counties"
Set oDS = .ImportData(szconn, , geoCountryUnitedStates, , geoImportExcelNamedRange)
Set RS = oDS.QueryAllRecords
RS.MoveFirst
High = 0
Do Until RS.EOF
If High < CInt(RS.Fields("I | K | D").Value) Then
High = CInt(RS.Fields("I | K | D").Value)
End If
RS.MoveNext
Loop
lRangeValues(1) = 0
lRangeValues(3) = High
zRangeNames(1) = "Low 0"
zRangeNames(2) = "Medium " & High / 2
zRangeNames(3) = "High " & High
Set oDM = oDS.DisplayDataMap( _
geoDataMapTypeShadedArea, _
, , , geoRangeTypeContinuous, geoRangeOrderHighToLow, 13, _
, lRangeValues, zRangeNames)
oDM.LegendTitle = "Sales By County for " & rcustid
oDS.Name = "Sales By County"
End With
'Change map to Data Map
oMap.MapStyle = geoMapStyleData
'Inactivate map
ws.Range("a1").Select
GoTo Done
ErrorHandler:
MsgBox Err.Description
Done:
End Sub Brian Wagner Last edited by Eric Frost; 09-26-2006 at 11:18 AM. Reason: added code tags (but not indentation) |
| |||
|
Hi, Please put next time code into [ code ] [ / code ] tags (without the spaces) for readability. Method 1: There is no collection of maps, so you have to keep the household of it yourself. A collection is basically just a linked list. But this method is as you self have sayed very memory consuming if you have lots of sheets with maps open. Method2: Looks nice, but I dont think you can move a map from control to other control. But what you sure can do, is move the whole control from the inactive sheet to the active sheet. Method3: Just in case 1 and 2 dont work you can have a mp control on all sheet, and open a map on active sheet and always close all other maps. But this will elapse more time.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
|
I have scrapped Method 1, and am trying Method 2. I have been able to delete the existing map on DactivateSheet and add map on Activate sheet, but I have not been able to move the control. Is there sample code somewhere on moving the MapPoint Control from one sheet to another? Tnks, Brian Wagner |
| |||
|
Hi, Never tryed it but should be possible. I have suspicion that if you have the control on a sheet, it is exacly the same as having the control on a form, right ? So dont add it on design time, but on runtime. To add: Code: // first create it etc... // Name of the control here is MP // Owner is the control where the control is sitting on, eg the sheet MP.BeginInit(); Owner.Controls.Add(MP); MP.EndInit(); MP.Visible = true; // I'm not sure on the sequence for the BeginInit :( // To move it: // Owner 2 is the second form / sheet MP.Visible = false; Owner.Controls.Remove(MP); Owner2.Controls.Add(MP); MP.Visible = true; // Again I'm not sure what to do with begin/end Init() Please feedback results, it can benefit other people a lot.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| New user: Exporting multiple data sets to excel | rpone605 | Products: Pushpin Tool, Single State Mapper | 0 | 06-20-2006 03:54 PM |
| Updating Maps in Excel without Mappoint | Cuda | MapPoint 2006/2009 Discussion | 5 | 02-06-2006 09:16 PM |
| Importing multiple maps into Excel | dadburne | MapPoint 2006/2009 Discussion | 5 | 10-19-2005 12:07 PM |
| Error with Multiple Symbol Maps | Anonymous | MapPoint 2006/2009 Discussion | 1 | 01-13-2005 03:31 PM |
| MPControl embedded in excel - excel loses functionality | ruyasan | MapPoint 2006/2009 Discussion | 2 | 05-20-2004 03:41 AM |
Cheap Flights Turkey
Cheap flights to Turkey are a reality when you book online with Holiday Hypermarket. Discover Turkish delights with Turkish cheap flights.
City Breaks
Book a city break with Travel Counsellors. A personal travel advisor will help you make the most of your city break.
Thailand Holiday
A Thailand Holiday has much to offer with historic culture, lively arts, beautiful beaches, a good nightlife, friendly and hospitable people and one of the best cuisines in the world.
Holidays to Barbados
Holidays to Barbados have so much to offer. Enjoy the beauty of this Caribbean island for less by booking your holiday through us.
Canaries
Find out all about the Canaries when you check out the ulookubook.com travel guides. Not only can you get a great holiday deal but you can find out useful information about potential holiday destinations.
Air Travel
Interested in air travel? Search and compare millions of holidays, flights and hotels with our help at Travel.co.uk
Cheap Holidays in Gran Canaria
Would you like to visit the Canary Islands, but you're on a budget? Get information on cheap holidays in Gran Canaria at On The Beach.