This article contains a sample script for opening all GRF files in a directory and exporting each to a vector PDF file.
Sub Main 'Opens all GRF file in directory 'Exports each to PDF (vector) Debug.Clear ''''''''''''' User Variables '''''''''''''''''' file_extension = "grf" file_directory = "C:\program files\golden software\grapher 15\samples\" export_format = "pdf" ''''''''''''''''''''''''''''''''''''''''''''''' Dim grapher As Object Set grapher = CreateObject("grapher.application") grapher.Visible = True Debug.Print grapher.Version file_extension = LCase(Right(file_extension,(Len(file_extension) - InStrRev(file_extension,".")))) If Len(file_directory)-InStrRev(file_directory,"\") <> 0 Then file_directory = file_directory + "\" grf_file = Dir( file_directory + "*." + file_extension) On Error GoTo FileError While grf_file <> "" 'Define output file directory & name export_file = file_directory + Left(grf_file, Len(grf_file)-(Len(grf_file)-InStrRev(grf_file,".")+1) ) + "." + export_format 'Opens a GRF file Set Plot = grapher.Documents.Open(file_directory + grf_file) Plot.Export2(export_file, False, , False, "pdfv") Debug.Print grf_file grf_file = Dir() 'get next file Wend grapher.Quit Exit Sub 'Print a meaningful error message for each file that did not grid correctly FileError: Debug.Print "Error: " + grf_file + " " + Err.Description Resume Next End Sub
Updated August 6, 2019
To run this script:
OR:
*********