Vbscript - Adobe 65024872 - InDesign CS4 - Mac Manual

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

Advertisement

Adobe InDesign CS4 Scripting Tutorial
//Move the graphic frame.
var myPageWidth = myDocument.documentPreferences.pageWidth;
var myTopMargin = myDocument.pages.item(0).marginPreferences.top;
myFrame.move([myPageWidth-myGraphicWidth, myTopMargin]);
//Apply a text wrap to the graphic frame.
myFrame.textWrapPreferences.textWrapType = TextWrapTypes.boundingBoxTextWrap;
myFrame.textWrapPreferences.textWrapOffset = [24, 12, 24, 12];
}

VBScript

Rem create an object style
On Error Resume Next
Set myObjectStyle = myDocument.ObjectStyles.Item("GraphicFrame")
If Error.Number <> 0 Then
Set myObjectStyle = myDocument.ObjectStyles.Add
myObjectStyle.Name = "GraphicFrame"
Error.Clear
End If
On Error GoTo 0
myObjectStyle.EnableStroke = True
myObjectStyle.StrokeWeight = 3
myObjectStyle.StrokeType = myDocument.StrokeStyles.Item("Solid")
myObjectStyle.StrokeColor = myDocument.Colors.Item("Red")
Rem Again, we'll use a JavaScript to get a file name.
Rem Disable normal error handling.
On Error Resume Next
Rem Create a JavaScript as a string.
myJavaScriptString = "var myTextFile = File.openDialog(""Choose a graphic
file"");myTextFile.fsName;"
Rem Run the JavaScript using DoScript.
myGraphicFileName = myInDesign.DoScript(myJavaScriptString,
idScriptLanguage.idJavascript)
If Error.Number = 0 Then
On Error GoTo 0
Set myGraphic = myDocument.Pages.Item(1).Place(myGraphicFileName)
Rem Since you can place multiple graphics at once, the place method
Rem returns an object collection. To get the graphic you placed, get the first
Rem item in the collection.
Set myGraphic = myGraphic.Item(1)
Rem Create an object style to apply to the graphic frame.
Rem The frame containing the graphic is the parent of the graphic.
Set myFrame = myGraphic.Parent
myFrame.ApplyObjectStyle myObjectStyle, True
Rem Resize the frame to a specific size.
myFrame.GeometricBounds = Array(0, 0, 144, 144)
Rem Fit the graphic to the frame proportionally.
myFrame.Fit idFitOptions.idProportionally
Rem Next, fit frame to the resized graphic.
myFrame.Fit idFitOptions.idFrameToContent
myBounds = myFrame.GeometricBounds
myGraphicWidth = myBounds(3) - myBounds(1)
Rem Move the graphic frame.
myPageWidth = myDocument.DocumentPreferences.PageWidth
myTopMargin = myDocument.Pages.Item(1).MarginPreferences.Top
Constructing a document 43

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs4

Table of Contents