Adobe 23101335 - Photoshop - PC Manual page 38

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

Advertisement

4. Enter the following code. The lines preceded by ' (single quotes) are comments, and will be
ignored by the scripting system. They're included to describe the operation of the script. As
you look through the script, you'll see how to create, then address each object.
Private Sub Command1_Click()
' Hello World Script
Dim appRef As New Photoshop.Application
' Remember current unit settings and then set units to
' the value expected by this script
Dim originalRulerUnits As Photoshop.PsUnits
originalRulerUnits = appRef.Preferences.RulerUnits
appRef.Preferences.RulerUnits = psInches
' Create a new 4x4 inch document and assign it to a variable.
Dim docRef As Photoshop.Document
Dim artLayerRef As Photoshop.ArtLayer
Dim textItemRef As Photoshop.TextItem
Set docRef = appRef.Documents.Add(4, 4)
' Create a new art layer containing text
Set artLayerRef = docRef.ArtLayers.Add
artLayerRef.Kind = psTextLayer
' Set the contents of the text layer.
Set textItemRef = artLayerRef.TextItem
textItemRef.Contents = "Hello, World!"
' Restore unit setting
appRef.Preferences.RulerUnits = originalRulerUnits
End Sub
5. Save the form.
6. Start Photoshop.
7. Return to Visual Basic and run the program. If you created a form, click the button you
created earlier.
8. Run the script. Photoshop will create a new document, add a new art layer, change the art
layer's type to text and set the text to "Hello, World!"
Photoshop 7.0 Scripting Guide
Scripting Photoshop
Your first Photoshop script
3
38

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop 7.0

Table of Contents