'For each GRD in the specified directory, the script creates a new window, a contour map in the window, saves and closes the SRF file. 'Then repeats for the next GRD in the directory. Sub Main ''''''''''''' User Variables '''''''''''''''''' 'You must enter the path to the grid files and the name of the BLN file file_directory = "C:\program files\golden software\surfer 10\samples\" 'make sure has a trailing \ file_extension = "grd" 'no "." preceding the extension ''''''''''''''''''''''''''''''''''''''''''''''' 'Opens Surfer Set SurferApp = CreateObject("surfer.application") SurferApp.Visible = True 'Progress for each file can be seen in the status bar of the application. 'Start the loop file_extension = LCase(Right(file_extension,(Len(file_extension) - InStrRev(file_extension,".")))) If Len(file_directory)-InStrRev(file_directory,"\") <> 0 Then file_directory = file_directory + "\" grid_file = Dir( file_directory + "*." + file_extension) On Error GoTo FileError While grid_file <> "" 'Opens new Surfer window Dim Plot As Object Set Plot = SurferApp.Documents.Add 'Creates the map Dim MapFrame As Object Set MapFrame = Plot.Shapes.AddContourMap(GridFileName:=file_directory + grid_file) 'Saves the file as SRF Plot.SaveAs (file_directory + Left(grid_file, Len(grid_file)-(Len(grid_file)-InStrRev(grid_file,".")+1) ) +".srf") Debug.Print grid_file Plot.Close grid_file = Dir() 'get next file Wend 'Closes Surfer SurferApp.Quit Exit Sub 'Error instructions FileError: Debug.Print "Error: " + grid_file + " " + Err.Description Resume Next End Sub