Hi,
I’m trying to create something similar to a table of contents by searching out words with a particular paragraph style and placing them into a text frame. InDesign allows for only one TOC and I need to have mulitple versions based on different paragraph styles. I can find the text based on the P style , but it’s returned to me as an object. Is there someway to change the object to a string? or am I going about this the wrong way? Any advice would be greatly appreciated. This is what I have so far.
tell application "Adobe InDesign CS2"
set find preferences to nothing
tell active document
set textRef to contents of story 1
set theStyle to paragraph style "author"
set foundItems to search textRef with find attributes {applied paragraph style:theStyle}
end tell
end tell
Thanks
Hi,
So, I’ve figured out how to select the words for the TOC based on an applied style,
but now I’m having difficulty in figuring out how to get the page number of the word.
It doesn’ seem to be a property of the word or of the parent. I’d appreciate any help with this.
property oldName : ""
set myWord to ""
tell application "Adobe InDesign CS2"
set getName to display dialog "Enter Character Name" buttons {"Cancel", "OK"} default answer oldName default button 2
set paragraphName to text returned of getName
set oldName to text returned of getName
tell active document
set textFrame to count of every text frame
repeat with x from 1 to textFrame
set Wordcount to count of every word of text frame x
repeat with n from 1 to Wordcount
set myproperties to name of applied character style of word n of text frame x
if myproperties is equal to paragraphName then
set myWord to myWord & return & (word n of text frame x)
end if
end repeat
end repeat
tell document preferences
set pageH to page height
set pageW to page width
end tell
set pageCount to number of pages
make new page
set newPage to pageCount + 1
tell page newPage
set TOC to make text frame
set geometric bounds of TOC to {0 + 0.25, 0 + 0.25, pageH - 0.25, pageW - 0.25}
set contents of TOC to myWord
end tell
end tell
end tell