Article View: adobe.scripting.indesign
Article #19167Re: tell text frame "Label" of page not possible - (AS)
From: Olav Kvern
Date: Wed, 15 Jan 2003 00:29
Date: Wed, 15 Jan 2003 00:29
119 lines
4967 bytes
4967 bytes
Armin--
Working with master page items is a bit of a problem--if you try to use:
set myTextFrame to (master page item 1 whose label is "TF1")
InDesign will copy all of the master page items to your document page. The only safe way to refer to a master page item is by its index, but the index of the master page item object you want (from the document page's point of view) is not the same as the index of the page item on the corresponding master spread.
If I were writing your script, therefore, I wouldn't bother with master page items. Instead, I would simply create the text frames on the pages.
If, however, you still want to use master page "template" text frames, try something like the following:
tell application "InDesign 2.0.1"
set theMarginPrefs to margin preferences
tell theMarginPrefs
set column count to 1
set column gutter to 10
set margin top to 15
set margin bottom to 10
set margin left to 7
set margin right to 7
end tell
set myDocument to make document
tell myDocument
set theViewPreferences to view preferences
tell theViewPreferences
set horizontal measurement units to millimeters
set vertical measurement units to millimeters
end tell
set theDocPrefs to document preferences
tell theDocPrefs
set pages per document to 1
set page orientation to landscape
set page height to 297
set page width to 210
end tell
end tell
set ruler origin of view preferences of myDocument to page origin
set myMarginPreferences to margin preferences
repeat with i from 1 to (count every page of myDocument)
tell page i of myDocument
set myTextFrame to make text frame with properties {geometric bounds:{margin top of myMarginPreferences, margin left of �
myMarginPreferences, 297 - (margin bottom of myMarginPreferences), �
210 - (margin right of myMarginPreferences)}}
end tell
end repeat
setnewframe(0, 10, 10, 35, "Headline", "TF1", myDocument) of me
setnewframe(7, 10, 10, 35, "text under headline", "TF2", myDocument) of me
setnewframe(290, 87, 5, 35, "page ^#", "PF1", myDocument) of me
tell myDocument
repeat with i from 1 to (count every page)
my myOverrideMasterTextFrame("TF1", page i, "Label should be TF1")
my myOverrideMasterTextFrame("TF2", page i, "Label should be TF2")
my myOverrideMasterTextFrame("PF1", page i, "Label should be PF1")
end repeat
end tell
end tell
--Handler for overriding master text frame.
on myOverrideMasterTextFrame(myLabel, myPage, myString)
tell application "InDesign 2.0.1"
tell myPage
set myAppliedMaster to applied master
set myIndex to my myFindMasterItemIndex(myLabel, myAppliedMaster)
if myIndex is not equal to "Label Not Found" then
set myTextFrame to master page item myIndex
set contents of myTextFrame to myString
end if
end tell
end tell
end myOverrideMasterTextFrame
--Handler for finding the index of the master page item.
on myFindMasterItemIndex(myLabel, myMasterSpread)
tell application "InDesign 2.0.1"
tell myMasterSpread
repeat with myCounter from 1 to (count page items)
if label of page item myCounter is myLabel then
--The master page items index is the inverse of the page item index on the master.
return ((count page items) - myCounter) + 1
exit repeat
end if
end repeat
end tell
end tell
return "Label Not Found"
end myFindMasterItemIndex
--Handler for creating a new master spread layout.
on setnewframe(y, x, h, w, c, thelabel, myDocument)
tell application "InDesign 2.0.1"
tell master spread 1 of myDocument
--set the master spread to a single page spread
if (count pages) > 1 then
repeat until (count pages) = 1
delete page 1
end repeat
end if
tell page 1
set thenewframe to make text frame with properties {geometric bounds:{y, (210 - (w + x)), (h + y), (210 - x)}, contents:c, label:thelabel}
tell text of thenewframe to set justification to right
end tell
end tell
end tell
end setnewframe
Thanks,
Ole
Technical Details
Message-ID:
<1de760bc.0@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de760bc.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f939a,9453c504c7e28b9b X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-01-14 16:40:57 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: tell text frame "Label" of page not possible - (AS) Message-ID: <1de760bc.0@WebX.la2eafNXanI> Date: Tue, 14 Jan 2003 16:29:37 -0800 References: <1de760bc.-1@WebX.la2eafNXanI> Lines: 124 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit