Adobe 23101764 Scripting Guide - Page 50
Advanced Visual Basic
UPC - 718659340025
View all Adobe 23101764 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 50 highlights
Scripting Photoshop 3 Advanced Scripting 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. 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 Photoshop CS Scripting Guide 46