'PRINT WITH DIALOG.BAS
'This script prints multiple graphs using a graph template and several data files.
'Press the Cancel button in the Open dialog box to end the loop.  Modify the paths
'in the script to match your template file path and data file path.

Sub Main

  'Create Grapher as an object
  Dim Grapher As Object

  'Start Grapher
  Set Grapher = CreateObject("Grapher.Application")

  'Remove quote from the following line to make Grapher visible
  Grapher.Visible(1)

  'Open Grapher's Open dialog box
  file$ = GetFilePath$(,"dat;xls",Grapher.Path+"\Samples\","Open",0)

  While file$ <> ""

    'Open the template file with data file selected in the Open dialog box
    Set doc = Grapher.Documents.Add(0,Grapher.Path+"\Templates\line scatter plot.grt",file$)

    'Print the graph
    doc.Print()

    'Close the plot window
    doc.Close(grfSaveChangesNo)

    'Open another data file file$ = GetFilePath$(,"dat;xls",Grapher.Path+"\Samples\","Open",0)
   Wend

'Close Grapher
Grapher.Quit()

End Sub
