Follow

How can I automate a find/replace in Surfer's worksheet?

This article contains a sample script for replacing a value in the worksheet with another value.

To run this script:

  1. Copy the script below, or download the attached BAS file: Replace.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 15\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. 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.
     

*********

'Replace.bas shows how to use the Edit | Replace function in automation
'to replace a value in the worksheet with another value.

'=====================================

Sub Main

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

'Open the worksheet document
	Set Wks = SurferApp.Documents.Open(SurferApp.Path+"\Samples\demogrid.dat")

'Specify the worksheet range
    Set WksRange = Wks.Columns(Col1:=1, Col2:=2)

'Replace "4" with the text "test"
	Set After = Wks.Range(1, "A", 1, "A")      'First cell

	WksRange.Replace(TargetStr:="4", ReplaceStr:="test", Current:=After, Scope:=wksFindScopeEntire, Method:=wksFindPhrase, ReplaceAll:=True)

End Sub

 

Updated October 11, 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.