Adobe 27510753 Scripting Guide - Page 158

Using guides and grids, Defining guides

Page 158 highlights

150 Working with Documents in VBScript Adobe InDesign CS2 Scripting Guide Rem You can use either a number or a measurement string to set the space above/below. .MinimumSpaceAboveAndBelow = "12p" Rem You can set the preview background color (which you'll only see Rem in Preview mode) to any of the predefined UIColor constants... .PreviewBackgroundColor = idUIColors.idGrassGreen Rem ...or you can specify an array of RGB values (with values from 0 to 255) Rem .PreviewBackgroundColor = Array(192, 192, 192) End With Using guides and grids Guides and grids make it easy to position objects on your document pages. Defining guides A guide in InDesign gives you an easy way to position objects on the pages of your document. Here's an example use of guides: Rem Guides.vbs Rem An InDesign CS2 VBScript Rem Create a new document, add guides, and set guide properties. Set myInDesign = CreateObject("InDesign.Application.CS2") Set myDocument = myInDesign.Documents.Add myPageWidth = myDocument.DocumentPreferences.PageWidth myPageHeight = myDocument.DocumentPreferences.PageHeight With myDocument.Pages.Item(1) Set myMarginPreferences = .MarginPreferences Rem Place guides at the margins of the page. With .Guides.Add .Orientation = idHorizontalOrVertical.idVertical .Location = myMarginPreferences.Left End With With .Guides.Add .Orientation = idHorizontalOrVertical.idVertical .Location = (myPageWidth - myMarginPreferences.Right) End With With .Guides.Add .Orientation = idHorizontalOrVertical.idHorizontal .Location = myMarginPreferences.Top End With With .Guides.Add .Orientation = idHorizontalOrVertical.idHorizontal .Location = (myPageHeight - myMarginPreferences.Bottom) End With Rem Place a guide at the vertical center of the page. With .Guides.Add .Orientation = idHorizontalOrVertical.idVertical .Location = (myPageWidth / 2) End With Rem Place a guide at the horizontal center of the page. With .Guides.Add .Orientation = idHorizontalOrVertical.idHorizontal .Location = (myPageHeight / 2) End With End With Horizontal guides can be limited to a given page, or can extend across all pages in a spread. With InDesign scripting, you can control this using the FitToPage property. (This property is ignored by vertical guides.) Rem SpreadAndPageGuides.vbs Rem An InDesign CS2 VBScript Rem Demonstrates the difference between spread guides and page guides. Set myInDesign = CreateObject("InDesign.Application.CS2")

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184

150
Working with Documents in VBScript
Adobe InDesign CS2 Scripting Guide
Rem You can use either a number or a measurement string to set the space above/below.
.MinimumSpaceAboveAndBelow = "12p"
Rem You can set the preview background color (which you’ll only see
Rem in Preview mode) to any of the predefined UIColor constants...
.PreviewBackgroundColor = idUIColors.idGrassGreen
Rem ...or you can specify an array of RGB values (with values from 0 to 255)
Rem .PreviewBackgroundColor = Array(192, 192, 192)
End With
Using guides and grids
Guides and grids make it easy to position objects on your document pages.
Defining guides
A
guide
in InDesign gives you an easy way to position objects on the pages of your document. Here’s an
example use of guides:
Rem Guides.vbs
Rem An InDesign CS2 VBScript
Rem Create a new document, add guides, and set guide properties.
Set myInDesign = CreateObject("InDesign.Application.CS2")
Set myDocument = myInDesign.Documents.Add
myPageWidth = myDocument.DocumentPreferences.PageWidth
myPageHeight = myDocument.DocumentPreferences.PageHeight
With myDocument.Pages.Item(1)
Set myMarginPreferences = .MarginPreferences
Rem Place guides at the margins of the page.
With .Guides.Add
.Orientation = idHorizontalOrVertical.idVertical
.Location = myMarginPreferences.Left
End With
With .Guides.Add
.Orientation = idHorizontalOrVertical.idVertical
.Location = (myPageWidth - myMarginPreferences.Right)
End With
With .Guides.Add
.Orientation = idHorizontalOrVertical.idHorizontal
.Location = myMarginPreferences.Top
End With
With .Guides.Add
.Orientation = idHorizontalOrVertical.idHorizontal
.Location = (myPageHeight - myMarginPreferences.Bottom)
End With
Rem Place a guide at the vertical center of the page.
With .Guides.Add
.Orientation = idHorizontalOrVertical.idVertical
.Location = (myPageWidth / 2)
End With
Rem Place a guide at the horizontal center of the page.
With .Guides.Add
.Orientation = idHorizontalOrVertical.idHorizontal
.Location = (myPageHeight / 2)
End With
End With
Horizontal guides can be limited to a given page, or can extend across all pages in a spread. With InDesign
scripting, you can control this using the
FitToPage
property. (This property is ignored by vertical guides.)
Rem SpreadAndPageGuides.vbs
Rem An InDesign CS2 VBScript
Rem Demonstrates the difference between spread guides and page guides.
Set myInDesign = CreateObject("InDesign.Application.CS2")