Create a text object using the cell contents from an Excel file via Surfer automation

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 copy/paste the contents from the cell in the worksheet into the plot window.  The script below shows how to do this via automation

 

To run this script:

  1. Copy the script below.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer\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 = CreateObject("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 November 2021

Was this article helpful?
1 out of 1 found this helpful

Comments

0 comments

Please sign in to leave a comment.