'Loop-SelectDataFile.bas loops the process of selecting a data file, gridding the data, 'creating a map, and saving the SRF file. 'By default, the X, Y and Z columns in the data file must be in columns A, B and C. 'You can change this in the GridData line. '================================================ Sub Main Dim SurferApp As Object Set SurferApp = CreateObject("Surfer.Application") SurferApp.Visible = True Do 'Opens a new plot document Dim Plot As Object Set Plot = SurferApp.Documents.Add 'Prompt the user for the name of the data file to process. InFile = GetFilePath(" ","DAT;TXT;CSV;XLS",CurDir(), "Select Data File", 0) If InFile = "" Then Exit Do 'Get file name without the extension (for example, "week5.txt becomse "week5") BaseName = InFile ExtStart = InStrRev(InFile, ".") If ExtStart >1 Then BaseName = Left(InFile,ExtStart-1) 'Create a grid from the specified data file GridFile = BaseName + ".grd" SurferApp.GridData (DataFile:= InFile, OutGrid:= GridFile) 'Creates a contour map from the grid file Dim Map As Object Set Map = Plot.Shapes.AddContourMap(GridFileName:=GridFile) 'Save to SRF Plot.SaveAs (FileName:=BaseName+".srf") 'Closes the plot Plot.Close Loop End Sub