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 13.
- 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.
- Copy the script below.
- Open Grapher and turn on the Script Manager by clicking View | Display | Script Manager.
- Press Ctrl+A to select all of the existing lines in the Script Manager and then press DELETE.
- Press Ctrl+V to paste it into the Script Manager.
- Click the Start/Resume icon ( ) in the Script Manager.
'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 September 24, 2018