The following script make a simple box and gives it a label name “BOX”
I would like to set the current selection to this object by referencing the object’s label name.
The following script works… however, the project that I am working on needs to select by label.
tell application "Adobe InDesign CS2"
activate
make document
tell document 1
set myBox to make new rectangle with properties {geometric bounds:{0, 0, 1, 1}, label:"BOX"}
set selection to myBox
end tell
end tell
I have try things like:
set selection to page items with properties {label:“BOX”}
I can’t seem to figure out the proper method/syntax.
If this is possible any information would be greatly appreciated.
CarbonQuark
Is there only 1 rectangle named ‘BOX’ ? hen you can do it like this:
tell application "Adobe InDesign CS2"
tell document 1
set everyRectangle to every rectangle
repeat with singleRectangle in everyRectangle
if label of singleRectangle is "BOX" then
-- do your thing !
exit repeat
end if
end repeat
end tell
end tell
I have a related problem. The above/below solutions don’t work for me.
If I type in “bob” as my value and in the script label palette, then it works. But I auto-generate the label and box with a variable and it cannot find it.
tell application "Adobe InDesign CS3"
return properties of every rectangle of document 1 whose label is "Arizona" ---> fails, only works with "bob"
--set selection to rectangle "Arizona" of page 1 ----> doesn't work
end tell
I’ve copied and pasted to eliminate keying errors. If I use “bob bob” it works as well. But anything else and it fails.
I’ve tried eliminating all the stupid things I can do, but having the script generate that usually is the best solution. Everything looks fine except when I run it. What am I overlooking? thanx, sam
For posterity, the issue is that I assumed if you’re trying to find any rectangle by name, you will not be able to if it is one that is anchored in a story.
I have to make a special statement to do that:
tell application "Adobe InDesign CS3"
set x to (items of all page items of stories of document 1) whose label is "Arizona"
return properties of item 1 of x --list object references of all page items returned from above
end tell