I’m trying to get every page number of a certain paragraph style. I know that this would usually be down automatically using InDesign’s CS built in indexing panel, but I’m building several complex indexes and it would help me to have the page numbers in the original Excel file so I can reparse it with InData to create these indexes.
I’ve whipped up a quick script and it works except it doesn’t follow the page order of the document it goes (I’m not staring on page 1) 23, 24, 25, 27, 26, 29, 28, 30 and on and on. Can anyone can see what I doing wrong?
tell application "InDesign CS"
activate
set myDoc to active document
tell myDoc
set myTextFrames to every text frame
set pageCounter to 1
set itemCounter to 1
set pageNumber to name of every page of myDoc
--repeat for every text frame
repeat with i from 2 to (count of myTextFrames)
tell text frame i
try
set myitems to (object reference of every paragraph whose name of applied paragraph style is "Item")
end try
end tell
--repeat for every item
repeat with p from 1 to (count of myitems)
tell application "Microsoft Excel"
activate
set cellNumber to "E" & itemCounter & ":E" & itemCounter
set value of cell cellNumber to (item pageCounter of pageNumber as string)
end tell
set itemCounter to itemCounter + 1
end repeat
set pageCounter to pageCounter + 1
end repeat
end tell
end tell
Many Thanks
Kieran