Sub Main

	'Initializes Surfer
	Dim SurferApp, Docs, Plot, Overlays, ContourLayer As Object
	Set SurferApp = CreateObject("Surfer.Application")
	SurferApp.Visible = True
	Set Docs = SurferApp.Documents

	'========================================
	'User Defined Variables
	'========================================
	'File path
	FilePath$ = "c:\users\leslie\desktop\"

	'Project file name (without file extension)
	SRFFile$ = "Contours"

	'Grid file name and extension (.grd, .asc, etc.)
	GRDFile$ = "Colorado"
	GRDExt$ = ".grd"

	'Map to use in the project. Can use numbers (1 is bottom object in Contents window) or name
	mapnum = 2   'or mapum="Map"

	'Layer to use in the map. Can use numbers (1 is bottom layer in map in Contents window) or name
	layernum=1   'or mapum="Contours-demogrid.grd"
	'========================================

	'Opens the original SRF file
	Set Plot = Docs.Open(FileName:=FilePath$+SRFFile$+".srf")

	'Assigns the contour map layer to the variable named "ContourLayer"
	Set ContourLayer = Plot.Shapes.Item(mapnum).Overlays.Item(layernum)

	'Changes the grid file for the contour layer to a different GRD file
	ContourLayer.GridFile=FilePath$+GRDFile$+GRDExt$

	'Loops through the axes to change the tick scaling to automatic
	For i=1 To 4
		Plot.Shapes.Item(mapnum).Axes(i).AutoScale=True
	Next

	'Saves the SRF file to a new name
	Plot.SaveAs(FileName:=FilePath$+SRFFile$+"_"+GRDFile$+".srf")

End Sub
