Print the graph in a Grapher template using as user-defined data file via automation

This article contains a sample script for printing multiple graphs from a template by asking the user to choose files from a dialog box.

To run this script:

  1. Copy the script below, or download the attached BAS file: print with dialog.BAS
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Grapher 13.
  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.


  1. Copy the script below.
  2. Open Grapher and turn on the Script Manager by clicking View | Display | Script Manager.
  3. Press Ctrl+A to select all of the existing lines in the Script Manager and then press DELETE.
  4. Press Ctrl+V to paste it into the Script Manager.
  5. Click the Start/Resume icon () in the Script Manager.



'This script prints multiple graphs using a graph template and several data files.
'Press the Cancel button in the Open dialog box to end the loop.  Modify the paths
'in the script to match your template file path and data file path.

Sub Main

  'Create Grapher as an object
  Dim Grapher As Object

  'Start Grapher
  Set Grapher = CreateObject("Grapher.Application")

  'Remove quote from the following line to make Grapher visible

  'Open Grapher's Open dialog box
  file$ = GetFilePath$(,"dat;xls",Grapher.Path+"\Samples\","Open",0)

  While file$ <> ""

    'Open the template file with data file selected in the Open dialog box
    Set doc = Grapher.Documents.Add(0,Grapher.Path+"\Templates\line scatter plot.grt",file$)

    'Print the graph

    'Close the plot window

    'Open another data file file$ = GetFilePath$(,"dat;xls",Grapher.Path+"\Samples\","Open",0) 

'Close Grapher 

End Sub


Updated September 24, 2018

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



Please sign in to leave a comment.