Follow

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 12\Scripter.
  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.
     

*********

'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 October 28, 2016

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

0 Comments

Please sign in to leave a comment.