'Lock All Objects In Directory.BAS
'This script opens all the GRF files in a directory.
'It then locks all the objects in each GRF and saves to the same GRF name.
'                            SKP 1/10

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)

  'Uncomment the next line to specify the directory in the script
  'Directory = Grapher.Path+"\Samples\"

  'Use this section if you want a dialog displayed to get the directory
  filetemp = GetFilePath$ (,"grf",Grapher.Path+"\Samples\","Directory to Change")
  Directory = Left(filetemp,InStrRev(filetemp,"\"))

  'Get all the file names
  file$ = Dir$(Directory + "*.grf")

  While file$ <> ""

    'Open the file in the directory in order
    Set doc = Grapher.Documents.Open(Directory+file$)

    'Loop through all objects and lock them
	i=1
	For i = 1 To doc.Shapes.Count
		Set itemi = doc.Shapes.Item(i)
		itemi.Locked = True
	Next i

    'Save the graph
	doc.Save

    'Close the plot window
    doc.Close()

    'Open the next file
    file$ = Dir$()

  Wend

  'Uncomment the next line to close Grapher
  'Grapher.Quit()

End Sub
