﻿'CopyPasteMaps.bas shows how to copy a map from one
'plot document window and paste into another.

'=============================

Sub Main

'Declare the variable that will reference the application
	Dim SurferApp As Object
	Set SurferApp = CreateObject("Surfer.Application")
	SurferApp.Visible = True

'Declares Plot as an object
	Dim Plot As Object
	Set Plot = SurferApp.Documents.Add

'Creates a contour map and assigns the map frame to the variable "MapFrame"
	Set MapFrame1 = Plot.Shapes.AddContourMap(GridFileName:=SurferApp.Path+"\samples\demogrid.grd")

'Selects MapFrame 1
	MapFrame1.Select

'Copies the selection
	Plot.Selection.Copy

'Declares Plot as an object
	Dim Plot2 As Object
	Set Plot2 = SurferApp.Documents.Add

'Creates a contour map and assigns the map frame to the variable "MapFrame"
	Set MapFrame2 = Plot2.Shapes.AddContourMap(GridFileName:=SurferApp.Path+"\samples\demogrid.grd")

'Positions MapFrame2 on the page
	MapFrame2.Left = 1
	MapFrame2.Top = 5.5

'Pastes the contents of the clipboard and assigns it to the variable "MapFrame3"
	Dim MapFrame3 As Object
	Set MapFrame3 = Plot2.Shapes.Paste(Format:=srfPasteBest)

'Positions the copied MapFrame3 on the page
	MapFrame3.Left = 1
	MapFrame3.Top = 10.75

End Sub
