Sub Main Dim SurferApp As Object Set SurferApp = CreateObject("Surfer.Application") SurferApp.Visible = True 'Specifies the grid and data files to use GridFile = SurferApp.Path+"\Samples\demogrid.grd" DataFile = SurferApp.Path+"\Samples\demogrid.dat" 'Uses Grid Residuals and stores the residuals in Column D Set Wks = SurferApp.GridResiduals(InGrid:=GridFile, DataFile:=DataFile, xCol:=1, yCol:=2, zCol:=3, ResidCol:=4) 'Saves the worksheet with the residuals Wks.SaveAs(FileName:="C:\temp\GridResiduals.dat") 'Closes the worksheet Wks.Close End Sub