How can I export only the objects I've selected using Surfer Scripter?

This article contains a sample script for exporting only the selected objects.

To run this script:

  1. Copy the script below, or download the attached BAS file: ExportSelectedOnly.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. Edit the Export File path on line 10 as desired.
  7. Click Script | Run to run the script.


'ExportSelectedOnly.bas opens a selected SRF file,
'selects a map, and exports the single map to the
'specified export file.

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

    ExportFile = "C:\temp\test.jpg"
	SRFfilepath = GetFilePath( , "srf",SurferApp.Path+"\samples\","Open SRF File",0)

'Opens the SRF file
    Dim Plot As Object
	Set Plot = SurferApp.Documents.Open(SRFfilepath)

'Assigns the map in the SRF file to the variable "MapFrame1"
'You may need to change the Index number so that the map in the SRF file is selected.
	Dim MapFrame1 As Object
	Set MapFrame1 = Plot.Shapes.Item(1)

'Selects the map

'Exports the selected objects only to the specified ExportFile path
	Plot.Export(FileName:=ExportFile, SelectionOnly:=True)

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.