Creating an index from a style sheet in Quark

The following Applescript creates an index from a style sheet in Quark. It searches through the Quark file for all text styled (in this example) as “1 title”, and outputs a text file with the text and the page number where it was found.

Usually, this script works great. The problem is that on certain Quark files, it doesn’t work that way. It doesn’t find the text style “1 title”, you have to enter a different style sheet. Instead of “1 title”, you have to enter “2 body”, and it will find the text that has been styled as “1 title” !!

Finding out that “2 body” works from a choice of a whole list of style sheets is the really vexing part.

  1. Why doesn’t “1 title” work?
  2. Why does substituting “2 body” work instead? It is a consistent problem for this Quark file.

THANK YOU in advance for any solution to this problem.

set recipe to ""
set thisline to ""

tell application "QuarkXPress Passport"
	activate
	tell document 1
		set pageList to every page
		repeat with aPage in pageList
			tell aPage
				set pageIndex to index
				set pageName to name
				set textBoxList to every text box
				repeat with aTextBox in textBoxList
					tell aTextBox
						set foundParagraphList to (every paragraph whose style sheet is "1 title")
						repeat with aParagraph in foundParagraphList
							set thisline to contents of aParagraph & pageName & return
							set recipe to recipe & thisline
						end repeat
					end tell --aTextBox
				end repeat
			end tell --aPage
		end repeat
	end tell --document
end tell

tell application "TextEdit"
	make new document at beginning with properties {text:recipe as Unicode text}
	activate
end tell --application