Sorry I don’t have the original. Years ago on CS6 I made a script that pulled InCopy stories out of an InDesign document based on text frames and parent stories, deduped the resulting list and then output the list to a Word document.
Opening the script with Adobe CC the alters some of the script such that the line reads
set «class UIAc» of «class pScr» to «constant elnteInA»
No idea how to fix. The script still works only now it doesn’t remove duplicates in the list of stories, so that if a story spans several pages, the story will be repeated for each page.
Here is the script as it stands now.
global WordDocName
global wrongText
global myStories
--set uniqueInCopyStories to {}
--set wrongText to "BASE"
tell application "System Events"
activate
set theDoc to choose file without multiple selections allowed
set theDocInfo to info for theDoc
set theDocName to name of theDocInfo
set theDocName to characters 1 thru -6 of theDocName as text
set WordDocName to theDocName as text
set WordDocName to WordDocName & ".docx" as text
display dialog WordDocName
set theDocName to theDocName & return
end tell
activate application "Adobe InDesign CC 2018"
tell application "Adobe InDesign CC 2018"
set «class UIAc» of «class pScr» to «constant elnteNvr»
ignoring application responses
open theDoc without «class uiDL»
end ignoring
set «class UIAc» of «class pScr» to «constant elnteInA»
end tell
set myStories to {}
my processFiles(theDoc)
set mylist to items 1 thru -1 of myStories
set firstList to mylist
set secondList to RemoveDuplicates(firstList)
--secondList --> {1, 2, 3, 4}
set mynewlist to {}
repeat with i from 1 to (count of secondList)
set myitem to item i of secondList as text
set end of mynewlist to myitem
end repeat
set mystring to mynewlist as string
--return mystring
my processWordDoc(theDocName, mystring, WordDocName)
on processFiles(theDoc)
tell application "Adobe InDesign CC 2018"
delay 30
(*
activate
ignoring application responses
open theDoc without dialog
end ignoring
--open theDoc
*)
tell «class pacd»
set myPages to every «class page»
repeat with i from 1 to count of myPages
tell item i of myPages
set myTextFrames to (every «class txtf» of item i of myPages)
repeat with aTextFrame in myTextFrames
if «class plnk» of «class strp» of aTextFrame is not «constant senmnada» then
if «class strp»'s «class plnk»'s «class lnkt» of aTextFrame is "InCopyMarkup" then
set mystorytitle to «class sTtl» of aTextFrame's «class strp»
set myLabel to «class ptag» of aTextFrame
set myText to characters 1 thru -1 of mystorytitle as string
--if myText does not contain wrongText then
set myStory to aTextFrame's «class strp»'s contents
copy "Page " & (name of item i of myPages) & " " & mystorytitle & return & myLabel & return & myStory & return & return to end of myStories
end if
end if
--end if
end repeat
end tell
end repeat
end tell
end tell
end processFiles
on processWordDoc(theDocName, mystring, WordDocName)
tell application "Microsoft Word"
activate
set newDoc to make new document
(*
copy styles from template active document template ¬
"Macintosh HD:Users:Shared:headings.dotm"
*)
copy theDocName & mystring to content of text object of newDoc
save as active document file name WordDocName
my textblue()
end tell
end processWordDoc
on textblue()
with timeout of 600 seconds
tell application "Microsoft Word"
set myFind to find object of text object of active document
tell myFind
clear formatting
set content of myFind to "(Page )(*^13)"
clear formatting of its replacement
set match wildcards to true
set content of its replacement to "\\1\\2"
set color of font object of its replacement to "blue"
¬
execute find replace replace all with match forward
end tell
end tell
end timeout
end textblue
on RemoveDuplicates(inputList)
set outputList to {}
repeat with i from 1 to length of inputList
-- We make testItem a single-item list to ensure
-- that sublists of the inputList are properly
-- looked for in the outputlist.
--
set thisItem to item i of inputList
set testItem to {thisItem}
if (outputList does not contain testItem) then
set end of outputList to thisItem
end if
end repeat
return outputList
end RemoveDuplicates
This is a partial log history of where I think the error is happening.
get every text frame of page id 192 of spread id 187 of document id 3
--> {text frame id 38186 of spread id 187 of document id 3, text frame id 38211 of spread id 187 of document id 3, text frame id 38237 of spread id 187 of document id 3, text frame id 38626 of spread id 187 of document id 3, text frame id 38551 of spread id 187 of document id 3, text frame id 38264 of spread id 187 of document id 3, text frame id 38601 of spread id 187 of document id 3, text frame id 38526 of spread id 187 of document id 3, text frame id 38289 of spread id 187 of document id 3, text frame id 38576 of spread id 187 of document id 3, text frame id 38501 of spread id 187 of document id 3, text frame id 38317 of spread id 187 of document id 3}
get item link of parent story of text frame id 38186 of spread id 187 of document id 3
--> nothing
get item link of parent story of text frame id 38211 of spread id 187 of document id 3
--> nothing
get item link of parent story of text frame id 38237 of spread id 187 of document id 3
--> nothing
get item link of parent story of text frame id 38626 of spread id 187 of document id 3
--> nothing
get item link of parent story of text frame id 38551 of spread id 187 of document id 3
--> nothing
What might I do to fix the script so there are no duplicates.
Model: iMac
AppleScript: 2.11
Browser: Safari 537.36
Operating System: macOS 10.14