Resize my graph using Grapher automation

This article contains a sample script for resizing an active graph.


To run this script:

  1. Click here to download the BAS file: Resize Graph.BAS
  2. Click Automation | Scripts | Run, select the BAS file from your downloads directory, and click Open.


  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 Start/Resume icon () in the Script Manager.


'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 = 14 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 August 13, 2019

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



Please sign in to leave a comment.