Defining And Applying Document Presets; Creating A Preset By Copying Values - Adobe 27510753 - InDesign CS2 - PC Manual

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

Advertisement

154
Working with Documents in VBScript
Rem At this point, you can perform any series of script actions that
Rem depend on the measurement units you've set. At the end of the
Rem script, reset the units to their original state.
With myDocument.ViewPreferences
.HorizontalMeasurementUnits = myOldXUnits
.VerticalMeasurementUnits = myOldYUnits
End With
Defining and applying document presets
InDesign document presets enable you to store and apply commonly used document setup information
(page size, page margins, columns, and bleed and slug areas). When you create a new document, you can
base the document on a document preset.

Creating a preset by copying values

To create a Document Preset using an existing document's settings as an example, open a document that has
the document setup properties that you want to use in the document preset, then run the following script:
Rem DocumentPresetByExample.vbs
Rem An InDesign CS2 VBScript
Rem Creates a document preset based on the current document settings.
Rem Assumes you have a document open.
Set myInDesign = CreateObject("InDesign.Application.CS2")
If myInDesign.Documents.Count > 0 Then
Set myDocument = myInDesign.ActiveDocument
Rem If the document preset "myDocumentPreset" does not already exist, create it.
Rem Disable normal error handling.
Err.Clear
On Error Resume Next
Set myDocumentPreset = myInDesign.DocumentPresets.Item("myDocumentPreset")
Rem If the document preset did not exist, the above line
Rem generates an error. Handle the error.
If (Err.Number <> 0) Then
Set myDocumentPreset = myInDesign.DocumentPresets.Add
myDocumentPreset.Name = "myDocumentPreset"
Err.Clear
End If
Rem Restore normal error handling.
On Error GoTo 0
Rem Fill in the properties of the document preset with the corresponding
Rem properties of the active document.
With myDocumentPreset
Rem Note that the following gets the page margins from the margin preferences
Rem of the document to get the margin preferences from the active page,
Rem replace "myDocument" with "myInDesign.activeWindow.activePage" in the
Rem following six lines (assuming the active window is a layout window).
.Left = myDocument.MarginPreferences.Left
.Right = myDocument.MarginPreferences.Right
.Top = myDocument.MarginPreferences.Top
.Bottom = myDocument.MarginPreferences.Bottom
.ColumnCount = myDocument.MarginPreferences.ColumnCount
.ColumnGutter = myDocument.MarginPreferences.ColumnGutter
.DocumentBleedBottomOffset = myDocument.DocumentPreferences.DocumentBleedBottomOffset
.DocumentBleedTopOffset = myDocument.DocumentPreferences.DocumentBleedTopOffset
.DocumentBleedInsideOrLeftOffset = myDocument.DocumentPreferences.DocumentBleedInsideOrLeft
Offset
.DocumentBleedOutsideOrRightOffset = myDocument.DocumentPreferences.DocumentBleedOutsideOrR
ightOffset
.FacingPages = myDocument.DocumentPreferences.FacingPages
.PageHeight = myDocument.DocumentPreferences.PageHeight
.PageWidth = myDocument.DocumentPreferences.PageWidth
.PageOrientation = myDocument.DocumentPreferences.PageOrientation
Adobe InDesign CS2 Scripting Guide

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs2

Table of Contents