Follow

How can I use Surfer Scripter to insert the cell contents from an Excel file as a text object?

To insert the contents of an Excel file cell into the plot document as a text object, you can open the data file in the Surfer worksheet and simply copy the contents from the cell in the worksheet and paste it into the plot window.

 

To run this script:

  1. Copy the script below.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 14\Scripter.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines then press Delete.
  5. Press Ctrl+V to paste the script into Scripter. 
  6. Click Script | Run to run the script.
     

*********

Sub Main
    Dim SurferApp, Plot, Wks As Object
    Set SurferApp = GetObject(, "Surfer.Application")
    SurferApp.Visible = True

    Set Plot = SurferApp.Documents.Add(srfDocPlot)

    'Open the data file in the worksheet
    Set Wks = SurferApp.Documents.Open(SurferApp.Path+"\samples\ColoradoCities.xls")

    'Set copy cell C5 in the worksheet
    Wks.Cells("C5").Copy

    'Paste cell contents into plot window
    Plot.Shapes.Paste

    Wks.Close
End Sub

 

The text object will remain static and won't update if the cell contents change in the Excel file. 

 

Updated February 15, 2017

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

0 Comments

Please sign in to leave a comment.