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:
- Uninstall one of the versions, so you just have one version on the computer.
- Try repairing the installation for the version you want the script to run in.
- Call Surfer using GetObject instead of CreateObject, and it will use whichever version of Surfer is opened on the computer.
- Unregister the version that is being called, and then register the version you want to use. For example,
- 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
- 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:
- Copy the script below, or download the attached BAS file: RegisterSurfer.BAS
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- Press Ctrl+V to paste the script into Scripter.
- 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