Follow

How can I write a script to print my Grapher template using all of the data files listed in a text file?

This article contains a sample script for printing multiple graphs from a template. Files are picked using an input file.


To run this script:

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

*********

'PRINT WITH FILE.BAS
'This script prints multiple graphs using a template graph and a text file
'consisting of data file names.  Please see "worksheet inputs.txt" as an
'example text file.  The text file must end with EOF.  Change the paths below
'to match your data and template graph paths.

Sub Main

  'Declare Grapher as an object
  Dim Grapher As Object

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

  'Makes Grapher visible
  Grapher.Visible(1)

  'Open the text file containing the data paths and file names
  Open Grapher.Path+"\Samples\worksheetinputs.txt" For Input As #1

  'Input a line from the text file above
  Line Input #1,wks$

  While wks$ <> "EOF"

    'Open the template file with one line (data file) from the text file
    Set doc = Grapher.Documents.Add(0,Grapher.Path+"\Templates\line scatter plot.grt",wks$)

    'Print the graph
    doc.Print()

    'Close the plot window
    doc.Close(grfSaveChangesNo)

    'Input the next line in the text file
    Line Input #1,wks$

  Wend

  Close #1

  Grapher.Quit()

End Sub

 

Updated April 17, 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.