Adobe 27510753 - InDesign CS2 - PC Manual page 44

Scripting guide
Hide thumbs Also See for 27510753 - InDesign CS2 - PC:
Table of Contents

Advertisement

36
Getting Started with InDesign Scripting
Set myTempDialogColumn = myBorderPanel.DialogColumns.Add
Set myRadioButtonGroup = myTempDialogColumn.RadiobuttonGroups.Add
Set myLeftRadioButton = myRadioButtonGroup.RadiobuttonControls.Add
myLeftRadioButton.StaticLabel = "Left"
myLeftRadioButton.CheckedState = True
Set myCenterRadioButton = myRadioButtonGroup.RadiobuttonControls.Add
myCenterRadioButton.StaticLabel = "Center"
Set myRightRadioButton = myRadioButtonGroup.RadiobuttonControls.Add
myRightRadioButton.StaticLabel = "Right"
Rem If the user clicked OK, then create the example document.
If myDialog.Show = True Then
Rem Get the values from the dialog box controls.
myString = myTextEditField.EditContents
myPointSize = myPointSizeField.EditValue
Rem Create a new document.
Set myDocument = myInDesign.Documents.Add
Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add
Rem Resize the text frame to the "live" area of the page (using the function "myGetBounds").
myBounds = myGetBounds(myDocument, myDocument.Pages.Item(1))
myTextFrame.GeometricBounds = myBounds
Rem Enter the text from the dialog box in the text frame.
myTextFrame.Contents = myString
Rem Set the size of the text to the size you entered in the dialog box.
myTextFrame.Texts.Item(1).PointSize = myPointSize
Rem Set the vertical justification of the text frame to the dialog menu choice.
Select Case myVerticalJustificationMenu.SelectedIndex
Case 0
myTextFrame.TextFramePreferences.VerticalJustification = idVerticalJustification.idTopAlign
Case 1
myTextFrame.TextFramePreferences.VerticalJustification =
Case Else
myTextFrame.TextFramePreferences.VerticalJustification = idTopAlign.idBottomAlign
End Select
Rem set the paragraph alignment of the text to the dialog radio button choice.
Select Case myRadioButtonGroup.SelectedButton
Case 0
Case 1
Case Else
End Select
Rem Remove the dialog box from memory.
myDialog.Destroy
End If
Rem Function for getting the bounds of the "live area"
Function myGetBounds(myDocument, myPage)
myPageHeight = myDocument.DocumentPreferences.PageHeight
myPageWidth = myDocument.DocumentPreferences.PageWidth
myTop = myPage.MarginPreferences.Top
myLeft = myPage.MarginPreferences.Left
myRight = myPage.MarginPreferences.Right
myBottom = myPage.MarginPreferences.Bottom
myRight = myPageWidth - myRight
myBottom = myPageHeight - myBottom
myGetBounds = Array(myTop, myLeft, myBottom, myRight)
End Function
2. Save the text as a plain text file with the file extension .vbs in the Scripts folder inside the Presets folder in
your InDesign folder.
3. Test the script by double-clicking the script name in the InDesign Scripts palette.
idVerticalJustification.idCenterAlign
myTextFrame.Texts.Item(1).Justification = idJustification.idLeftAlign
myTextFrame.Texts.Item(1).Justification = idJustification.idCenterAlign
myTextFrame.Texts.Item(1).Justification = idJustification.idRightAlign
Adobe InDesign CS2 Scripting Guide
¬

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs2

Table of Contents