Run a script in a specific version of Surfer

We strongly recommend keeping only the most recent version of Surfer that you are licensed for installed.  However, if a workflow requires you to have multiple versions installed, you can call a specific version via automation.
In most cases, if you have more than one version of Surfer installed, the script will run in the version of Surfer was last opened with administrator rights. So if you have Surfer 12 and Surfer 22 installed, you can open Surfer 12 as administrator, close it, run the script and it will run in Surfer 12. Then open Surfer 22 as administrator, close it, run the script and it will run in Surfer 22.

In some cases, Windows configuration problems will prevent a script from running in one version or the other. In this case, you can try one of these methods:

  1. Uninstall one of the versions, so you just have one version on the computer.
  2. Try repairing the installation for the version you want the script to run in.
  3. Call Surfer using GetObject instead of CreateObject, and it will use whichever version of Surfer is opened on the computer.
  4. Unregister the version that is being called, and then register the version you want to use. For example,
    1. Click the Windows Start button and in the Run box enter the filepath to the version of Surfer you want to unregister in quotes, followed by /Unregister. For example: "c:\program files (x86)\golden software\surfer8\surfer.exe" /Unregister
    2. Then register the version you do want to run by clicking the Windows Start button and in the Run box entering the filepath to the version of Surfer you want to register in quotes, followed by /Register. For example:"c:\program files\golden software\surfer 16\surfer.exe" /Register

 

You can also use the Shell command in the script to specifically state which version of Surfer to open. For a full script example, see below.

To run this script:

  1. Copy the script below, or download the attached BAS file: RegisterSurfer.BAS
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer.
  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 
'Open Surfer 16 and use that instance to run the script
Shell "c:\program files\golden software\Surfer 16\Surfer.exe" 
Wait 4 
Dim SurferApp, Plot, MapFrame As Object 
Set SurferApp = GetObject(,"Surfer.Application") 
SurferApp.Visible = True 
Set Plot = SurferApp.ActiveDocument 

'Creates a contour map and assigns the map frame to the variable "MapFrame"
Set MapFrame = Plot.Shapes.AddContourMap(GridFileName:=SurferApp.Path+"\Samples\demogrid.grd") 
End Sub

 

Updated November 2021

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

Comments

0 comments

Please sign in to leave a comment.