SaveAs method
Saves the specified map or template. Not available for embedded maps or the MapPoint Control.
Applies to
Objects: Map
Syntax
object.SaveAs([FileName], [SaveFormat], [AddToRecentFiles])
Parameters
Part |
Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
object |
Required. An expression that returns a Map object. | ||||||||||||||||||
FileName |
Optional String. Name of the file to save. You can specify the full path. If not specified, the default file name is used. | ||||||||||||||||||
SaveFormat |
Optional GeoSaveFormat. Format of the file to save. Default is geoFormatMap.
| ||||||||||||||||||
AddToRecentFiles |
Optional Boolean. Adds the file to the Most Recently Used (MRU) list on the File menu. Default is True. |
Remarks
If a file of the same name and format already exists, that file is overwritten. To avoid overwriting a file, check for the existence of a file before saving.
The SaveAs method invalidates any existing Recordset objects.
For finer control in creating Web pages, use the Add method and then the Save method on the SavedWebPages collection.
For the MapPoint Control, use the SaveMapAs method on a MappointControl object.
Example
[Microsoft Visual Basic 6.0]
Sub SaveTemplate()
Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objRoute As MapPoint.Route
Dim objLoc As MapPoint.Location
'Set up the application
Set objMap = objApp.ActiveMap
Set objRoute = objMap.ActiveRoute
objApp.Visible = True
objApp.UserControl = True
'Create a route
objRoute.Waypoints.Add objMap.FindResults("Seattle, WA").Item(1)
objRoute.Waypoints.Add objMap.FindResults("Redmond, WA").Item(1)
objRoute.Calculate
'Save the map as a template
objMap.SaveAs "Saved Template", geoFormatTemplate, True
End Sub
[C#]
void SaveTemplate()
{
MapPoint.ApplicationClass objApp = new MapPoint.ApplicationClass();
MapPoint.Map objMap = null;
MapPoint.Location objLocStart = null;
MapPoint.Location objLocEnd = null;
MapPoint.Route objRoute = null;
object key = 1;
//Set up the application
objMap = objApp.ActiveMap;
objRoute = objMap.ActiveRoute;
objApp.Visible = true;
objApp.UserControl = true;
//Get start and end locations for route
objLocStart = (MapPoint.Location) objMap.FindResults("Seattle, WA").get_Item(ref key);
objLocEnd = (MapPoint.Location) objMap.FindResults("Redmond, WA").get_Item(ref key);
//Create and Calculate a route
objRoute.Waypoints.Add(objLocStart,"Start");
objRoute.Waypoints.Add(objLocEnd,"End");
objRoute.Calculate();
//Save the map as a template
objMap.SaveAs("Saved Template", MapPoint.GeoSaveFormat.geoFormatTemplate, true);
}
Note This sample code is specifically for use in MapPoint North America; it is for illustration purposes only.