Export multiple graphs in a Plot Document to separate files in Grapher Automation

This article contains a sample script for looping through multiple graphs in a single project's plot document and exporting each graph individually.


To run this 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 green arrow Start/Resume icon in the Script Manager. 

Sub Main

'Initializes Grapher
Dim Grapher As Object
Set Grapher = CreateObject("Grapher.Application")
Grapher.Visible = True

'User-defined variables
inpath$ = Grapher.Path+"\Samples\"
filename$ = "BarCharts.gpj"
outpath$ = "C:\temp\"

'Open an existing document
Set PlotDoc = Grapher.Documents.Open(inpath$+filename$)

'Loop through graphs, selecting and exporting each individually
For i=1 To PlotDoc.Shapes.Count
	graphname = PlotDoc.Shapes.Item(i).Name
	Debug.Print i
Debug.Print "Done"

End Sub


Updated March 2020

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



Please sign in to leave a comment.