How can I copy a graph into another project using Grapher automation?

This article contains a sample script for copying a currently open graph to another Grapher window and resizing the graph in the new window.

To run this script:

  1. Open the Grapher file containing the graph(s) you wish to resize.
  2. Copy the script below, or download the attached BAS file: Resize Graph.BAS.
  3. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Grapher 12\Scripter.
  4. Double click on Scripter.exe to launch Scripter.
  5. Press Ctrl+A to select all of the existing lines then press Delete.
  6. 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.
  7. Click Script | Run to run the script.


'Resize selected objects
Sub Main

'Create Grapher as an Object
Dim Grapher As Object

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

Grapher.Visible = True

'Create a new document window
Set Plot = Grapher.Documents.Active

'Set the Shapes object -- this will be used to count the number of objects later
Set Shapes = Plot.Shapes

'Loop through all objects on the page looking for a graph
For i = 1 To Shapes.Count
    If Shapes.Item(i).Type = grfShapeGraph Then
        'If it finds a graph, change the width and height
        'To set a different size, change the numbers in () after .width and .height
    End If
'Go to next object
Next i
'All graphs have now been changed

End Sub


Updated April 14, 2017

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.