
Photoshop CS3
Adobe Photoshop CS3 Scripting Guide Scripting Photoshop CS3 62
set display dialogs to theStartDisplayDialogs
end tell
2. In Photoshop CS3, choose Photoshop > Preferences > Units & Rulers to verify that your preferences
have been returned to your original settings.
3. After viewing the document in Photoshop CS3, close the document without saving it.
4. Save the script as
HelloWorldDoc.
VBS
➤ To work with document preferences:
1. Create the following script. See ‘Creating and Running a VBScript’ on page 16 for details.
'create variables for default preferences, new preferences
Dim startRulerUnits
Dim startTypeUnits
Dim docWidthInInches
Dim docHeightInInches
Dim resolution
Dim helloWorldStr
Dim appRef
Set appRef = CreateObject("Photoshop.Application")
'assign default preferences to save values in variables
startRulerUnits = appRef.Preferences.RulerUnits
startTypeUnits = appRef.Preferences.TypeUnits
startDisplayDialogs = appRef.DisplayDialogs
'set new preferences and document defaults
appRef.Preferences.RulerUnits = 2 'for PsUnits --> 2 (psInches)
appRef.Preferences.TypeUnits = 1 'for PsTypeUnits --> 1 (psPixels)
appRef.DisplayDialogs = 3 'for PsDialogModes --> 3 (psDisplayNoDialogs)
docWidthInInches = 4
docHeightInInches = 2
resolution = 72
helloWorldStr = "Hello, World!"
'see if any documents are open
'if none, create one using document defaults
If appRef.Documents.Count = 0 Then
appRef.Documents.Add docWidthInInches, docHeightInInches, resolution,
helloWorldStr
End If
'restore beginning preferences
appRef.Preferences.RulerUnits = startRulerUnits
appRef.Preferences.TypeUnits = startTypeUnits
appRef.DisplayDialogs = startDisplayDialogs
2. Double click the file name in Windows Explorer to run the script.
3. In Photoshop CS3, choose Edit > Preferences > Units & Rulers to verify that your preferences have
been returned to your original settings.