This article contains a sample script for opening all GRF files in a selected directory and locking all items in the GRF.
To run this script:
- Click here to download the BAS file:Lock all Objects in Directory.BAS .
- Click Automation | Scripts | Run, select the BAS file from your downloads directory, and click Open.
- Copy the script below.
- Open Grapher and turn on the Script Manager by clicking View | Display | Script Manager.
- Press Ctrl+A to select all of the existing lines in the Script Manager and then press DELETE.
- Press Ctrl+V to paste it into the Script Manager.
- Click the Start/Resume icon ( ) in the Script Manager.
'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
Updated October 16, 2018