Sub Main

'Declare the variable that will reference the application
	Set SurferApp = CreateObject("Surfer.Application")
	Dim Doc As Object
	SurferApp.Visible = True

'Declares Plot as an object
	Dim Plot As Object
	Set Plot = SurferApp.Documents.Add(srfDocPlot)

'Creates a base map from DemoRect.bln
	Set MapFrame1 = Plot.Shapes.AddBaseMap(ImportFileName:=SurferApp.Path+"\Samples\DemoRect.bln")
	Set BaseLayer = MapFrame1.Overlays(1)

'Creates a post map from Demogrid.dat
	Set MapFrame2 = Plot.Shapes.AddPostMap(DataFileName:=SurferApp.Path + "\Samples\Demogrid.dat")
	Set PostLayer = MapFrame2.Overlays(1)

'Creates a contour map from Demogrid.grd
	Set MapFrame3 = Plot.Shapes.AddContourMap(GridFileName:=SurferApp.Path+"\Samples\Demogrid.grd")
	Set ContourLayer = MapFrame3.Overlays(1)

'Selects the three maps
	MapFrame1.Selected = True
	MapFrame2.Selected = True
	MapFrame3.Selected = True

'Overlays the maps and set the overlay to NewMapFrame
	Set NewMapFrame = Plot.Selection.OverlayMaps

'Sets the properties for NewMapFrame
	NewMapFrame.SetLimits(0.75,4.5,0.75,3.23)
	NewMapFrame.xMapPerPU = 1
	NewMapFrame.yMapPerPU = 1
	NewMapFrame.Top = 5

'Sets the order of the contour map within the overlay
	ContourLayer.SetZOrder(Zorder:=srfZOToBack)

'Break apart the contour map
	Set MapFrame4 = NewMapFrame.Overlays.BreakApart(pOverlay:=ContourLayer)

'Get grid limits for ContourMap and assign to variable
	Dim Grid As Object
	ContourLayerxMax = ContourLayer.Grid.xMax
	ContourLayerxMin = ContourLayer.Grid.xMin
	ContourLayeryMin = ContourLayer.Grid.yMin
	ContourLayeryMax = ContourLayer.Grid.yMax

'Set limits for ContourMap to grid limits and reset scale
	MapFrame4.SetLimits(ContourLayerxMin, ContourLayerxMax, ContourLayeryMin, ContourLayeryMax)
	MapFrame4.xMapPerPU=1.5
	MapFrame4.yMapPerPU=1.5
	MapFrame4.Top = 10.5

End Sub
