How can I use a script to save my Grapher file and then export the graph to a file with that same name?

This article contains a sample script for saving and exporting an open file to the same file name.

To run this script:

  1. Copy the script below, or click here to download the BAS file: save and export.BAS
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Grapher 13.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines then press Delete.
  5. 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.
  6. Click Script | Run to run the script.

OR:

  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.

*********

'Uses the existing open window
'Saves to existing format and exports to PDF and PNG
Sub Main
	'Create Grapher as an Object
	Dim Grapher As Object

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

	'Make Grapher visible
	Grapher.Visible = True

	'Get the current plot window
	Set Plot1 = Grapher.Documents.Active

	'Save file to existing name
	Plot1.Save

	'Exports file to PDF with same name and location as plot - uses defaults
	Plot1.Export2(Left(Plot1.FullName,Len(Plot1.FullName)-3) + "pdf",False,"Defaults=0",True,"pdfv")

	'Exports file to PNG with same name and location as plot - uses defaults
	Plot1.Export2(Left(Plot1.FullName,Len(Plot1.FullName)-3) + "png",False,"Defaults=0", True, "png")

End Sub

 

Updated September 24, 2018

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

Comments

0 comments

Please sign in to leave a comment.