Adobe 23101764 - Photoshop CS - PC Manual page 50

Scripting guide
Hide thumbs Also See for 23101764 - Photoshop CS - PC:
Table of Contents

Advertisement

3.4.2 Advanced Visual Basic
The following Visual Basic code sample is broken down into four sections, the first of which
deals with configuring document preferences.
Document Preferences
In this code segment, variables are declared and a Photoshop Application object is created.
Default configuration settings for the application are saved into variables so that they can be
restored later when the script completes. These are the default configurations you most
probably set up using the File/Edit/Preferences dialog when you initially installed and
configured Photoshop.
The script goes on to define new preferences for rulers and units and sets these to inches and
pixels, respectively. The psDisplayNoDialogs enumeration is specified so that the script runs
without user intervention. Users will not, in other words, be required to press "OK" each time
the script generates a new dialog for display.
Next, variables are declared that store document dimensions in inches and document
resolution in pixels. A display resolution is declared and the text "Hello, World!" is assigned to
a string variable.
Finally, a document object is created, if one does not already exist.
Photoshop CS Scripting Guide
Dim startRulerUnits As Photoshop.PsUnits
Dim startTypeUnits As Photoshop.PsTypeUnits
Dim startDisplayDialogs As Photoshop.PsDialogModes
Dim docWidthInInches As Integer
Dim docHeightInInches As Integer
Dim docWidthInPixels As Integer
Dim docHeightInPixels As Integer
Dim resolution As Integer
Dim helloWorldStr As String
Dim app As Photoshop.Application
Dim docRef As Photoshop.Document
Dim textColor As Photoshop.SolidColor
Dim newTextLayer As Photoshop.ArtLayer
Dim Preferences As Photoshop.Preferences
Set app = New Photoshop.Application
startRulerUnits = app.Preferences.RulerUnits
startTypeUnits = app.Preferences.TypeUnits
startDisplayDialogs = app.DisplayDialogs
Scripting Photoshop
Advanced Scripting
3
46

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs

Table of Contents