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:
- Copy the script below, or download the attached BAS file: print with dialog.bas.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Grapher 12\Scripter.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- 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.
- Click Script | Run to run the script.
'PRINT WITH DIALOG.BAS '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 'Grapher.Visible(1) '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 doc.Print() 'Close the plot window doc.Close(grfSaveChangesNo) 'Open another data file file$ = GetFilePath$(,"dat;xls",Grapher.Path+"\Samples\","Open",0) Wend 'Close Grapher Grapher.Quit() End Sub
Updated October 28, 2016