How can I choose a specific worksheet from my Excel file to grid via Surfer automation?

This article contains a sample script for choosing a specific sheet in an Excel XLS file to use for gridding. 

To run this script:

  1. Copy the script below, or download the attached BAS file: Multisheet XLS.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 16.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines then press Delete.
  5. If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
  6. Click Script | Run to run the script.


'Multisheet XLS.bas shows how to specify a particular sheet in
'an Excel XLS or XLSX file to use for gridding.


Sub Main

	Dim SurferApp As Object
	Set SurferApp = CreateObject("Surfer.Application")
	SurferApp.Visible = True

	Dim Plot As Object
	Set Plot = SurferApp.Documents.Add(srfDocPlot)

'Use GridData2 to grid data and specify data file options, such as XLS sheet name
	SurferApp.GridData2("c:\temp\Book1.xlsx", DataFileOptions:="sheet=Test", ShowReport:=False, OutGrid:="c:\temp\test.grd")

'Create a contour map from the grid file

'Use AddPostMap2 to create a post map from a data file and specify data file options, such as XLS sheet name
	Plot.Shapes.AddPostMap2("c:\temp\Book1.xlsx", DataFileOptions:="sheet=Test")


End Sub


Updated November 13, 2018

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.