Adobe 27510753 - InDesign CS2 - PC Manual page 34

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

Advertisement

26
Getting Started with InDesign Scripting
end tell
end tell
end tell
--myGetBounds is a handler that returns the bounds of the "live area" of a page.
on myGetBounds(myDocument, myPage)
tell application "Adobe InDesign CS2"
set myPageHeight to page height of document preferences of myDocument
set myPageWidth to page width of document preferences of myDocument
set myLeft to left of margin preferences of myPage
set myTop to top of margin preferences of myPage
set myRight to right of margin preferences of myPage
set myBottom to bottom of margin preferences of myPage
end tell
set myRight to myLeft + (myPageWidth - (myRight + myLeft))
set myBottom to myTop + (myPageHeight - (myBottom + myTop))
return {myTop, myLeft, myBottom, myRight}
end myGetBounds
4. Save the script.
5. Run the new script.
VBScript
To create the script:
1. Start any text editor (Notepad, for example).
2. Make sure that you have the Hello World document open; if you've closed the document without saving it,
simply run the previous script again to make a new Hello World document.
3. Enter the following code.
Rem Improved "Hello World"
Set myInDesign = CreateObject("InDesign.Application.CS2")
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.idLeftAlign
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
set justification to center align
end tell
Adobe InDesign CS2 Scripting Guide

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs2

Table of Contents