'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:\Users\Katie\Desktop\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
	MapFrame1.Select

'Exports the selected objects only to the specified ExportFile path
	Plot.Export(FileName:=ExportFile, SelectionOnly:=True)

End Sub
