QX script to copy all of selected stylesheet to a new doc?

this sounds simple in my head but can’t seem to get off the ground in making it work

Could someone help with a script to copy all of the text in a quark doc of a specific stylesheet to a new doc

I have never written scripts for Quark and could use a little direction

here is my start at it

   tell application "QuarkXPress copy"
   tell page 1 of front document
      save (every word of every text box whose font is "Futura book" and size is "7 pt") as "ascii text" in "Scratch Disk HD:Users:joe:Desktop:text1"
   end tell
   (*tell stories of text boxes of page 2 of front document
      save (paragraphs whose font is "Futura book" and size is "7 pt") in "Scratch Disk HD:Users:joe:Desktop:text2"
   end tell
   *)
end tell

it only will give me the last item with the matching attributes not all of the items

any leads?

the following will make a list out of every word whose font is Furtura book, and size is 7. You would then need to deal with the list in a way that will give you the desired formating for your ascii text. This returns each word as a seperate word in a list of words, ie {“Test”, “5”, “Test”, “3”, “Test”, “4”, “Test”, “2”, “Test”, “1”} coercing to string returns “Test5Test3Test4Test2Test1”, I doubt that either of these matches the result you want, so you would need to add some code to make it work for your situation.

tell application "QuarkXPress™ 4.11"
	tell page 1 of front document
		set x to (every word of story 1 whose (font is "Futura Book" and size is "7 pt")) of every text box
	end tell
end tell
set AppleScript's text item delimiters to ","
set linebreaks to ""
tell application "QuarkXPress copy"
	tell pages of front document
		set TextSaved to (every word of every text box whose font is ¬
			"Futura book" and size is "7 pt") as text
		--make new page at the end of the document
		--make new text box at end of document with TextSaved
	end tell
	--save text TextSaved as "ascii text" in "Scratch Disk HD:Users:joe:Desktop:tester:mytext1.txt"
	--end tell
end tell
--set TextSaved to summarize TextSaved using delimeter "," --I know this wont work
(*tell application "Finder"
	repeat with i from 1 to (count items in TextSaved)
		set linebreaks to (linebreaks & (item i of TextSaved) & return) as string
	end repeat
end tell*)
open for access file "Scratch Disk HD:Users:joe:Desktop:tester:mytext6.xls" with write permission
--set thelist to read (TextSaved) as list using delimiter ", "
--save thelist --to "mytext.txt" as text
write linebreaks to file "Scratch Disk HD:Users:joe:Desktop:tester:mytext6.xls"

as you all can see from my code i have tried multiple ways of coercing this copy to fit my needs but maybe if i give a little background someone will understand what i need

here it goes

I have a 16 pg newsletter that has catalog numbers in a stylesheet

i only need the catalog numbers “MAB4360, MAB4381” (we also have catalog numers that begin with various other prefixes and some are just numbers)

basicly i need to bring the list of catalog numbers into an excel file (delimeted text is fine) for our Sales team to generate a price list of the items in the newsletter

probably a whole lot of information that no one cares about but i think it can help to understand the problem

heres a picture

tell document 1 of application "QuarkXPress 4.11"
	set target_style to character spec "TargetStyleSheetName"
	set word_list to every word of every story whose character style is target_style
end tell
set out_filename to ((path to desktop folder) as string) & "Output"
set out_file_id to open for access out_filename with write permission
repeat with i from 1 to count of items of word_list
	write (item i of word_list) & return to out_file_id
end repeat
close access out_file_id

Change TargetStyleSheetName to whatever character style sheet you’ve got applied to the text you want to extract. You can also replace the return with whatever delimeter you want in the output file. You can then bring the output file into Excel and do whatever other processing you want.

I am using paragraph stylesheets and when i try to use “stylespec ‘mystylename’” it gets stuck in reply loop

You’re using paragraph stylesheets? I thought you were trying to extract a word (the catalog number) from each line? If you extract text according to paragraph stylesheets you’re going to get an entire line at a time, minimum. Is that what you want?