Adobe 65024872 - InDesign CS4 - Mac Manual page 28

Scripting guide
Hide thumbs Also See for 65024872 - InDesign CS4 - Mac:
Table of Contents

Advertisement

Adobe InDesign CS4 Scripting Tutorial
Either open the
script:
1. Start any text editor (for example, Notepad).
2. Enter the following code:
Set myInDesign = CreateObject("InDesign.Application.CS4")
Rem Enter the name of a font on your system, if necessary.
Set myFont = myInDesign.Fonts.Item("Arial")
Set myDocument = myInDesign.ActiveDocument
Set myPage = myDocument.Pages.Item(1)
Rem Get page width and page height using the function "myGetBounds".
myBounds = myGetBounds(myDocument, myPage)
Set myTextFrame = myPage.TextFrames.Item(1)
Rem Resize the text frame to match the publication margins.
myTextFrame.GeometricBounds = myBounds
Set myParagraph = myTextFrame.Paragraphs.Item(1)
Rem Change the font, size, and alignment.
If TypeName(myFont) <> "Nothing" Then
myParagraph.AppliedFont = myFont
End If
myParagraph.PointSize = 48
myParagraph.Justification = idJustification.idCenterAlign
Rem myGetBounds is a function that returns the bounds
Rem of the "live area" of a page.
Function myGetBounds(myDocument, myPage)
myPageWidth = myDocument.DocumentPreferences.PageWidth
myPageHeight = myDocument.DocumentPreferences.PageHeight
If myPage.Side = idPageSideOptions.idLeftHand Then
Else
End If
myY1 = myPage.marginPreferences.Top
myX2 = myPageWidth - myX2
myY2 = myPageHeight - myPage.MarginPreferences.Bottom
myGetBounds = Array(myY1, myX1, myY2, myX2)
End Function
3. Save the text as a plain text file with the file extension
on page
Once you've opened or created the script file, you can run the script from the InDesign Scripts panel.
ImprovedHelloWorld.vbs
myX2 = myPage.MarginPreferences.Left
myX1 = myPage.MarginPreferences.Right
myX1 = myPage.MarginPreferences.Left
myX2 = myPage.MarginPreferences.Right
6).
tutorial script, or perform the following steps to create the
in the Scripts folder (see
.vbs
Adding features to "Hello World" 28
"Installing scripts"

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs4

Table of Contents