XPress 6 save each page as ps

Hello everyone,
I’m currently trying to port a script from XPress 5 to XPress 6. This is really the only thing keeping me from migrating the production department to OS X entirely. I have no desire to hit print 219 times to create individual postscript files.

So far by comparing code from the “save each page as eps”, I’ve been able to get it to compile and function BUT, Instead of creating single page ps files it’s creating multiple, multi-page ps files before timing out with an Apple event error -1712
Here’s what I have so far (this is all ripped from previous code and massaged)

tell application "QuarkXPress"
	activate
	
	try
		display dialog "To specify the print settings, modify the Print dialog and choose Capture Settings, before running this script." buttons {"Cancel", "Continue"} default button "Continue" with icon note
		if button returned of result is "Cancel" then error "User canceled." number -128
		
		-- This section will allow the user to specify which document to use, either the active document or browse to a document
		if (exists document 1) and doc format of document 1 is in {"XDOC", "XTMP", "XPRJ", "XPT"} then
			set whatDoc to button returned of (display dialog ¬
				"Would you like to use the Active document or choose a new document?" buttons {"Cancel", "Choose", "Active"} default button "Active")
			if whatDoc is "Choose" then
				set File_Location to ((choose file of type {"XDOC", "XTMP", "XPRJ", "XPT"} with prompt ""Select a QuarkXPress document."") as text)
				try
					open alias File_Location use doc prefs yes remap fonts no do auto picture import no
				end try
			end if
			if whatDoc is "Cancel" then error "User canceled." number -128
		else
			set File_Location to ((choose file of type {"XDOC", "XTMP", "XPRJ", "XPT"} with prompt ""Select a QuarkXPress document."") as text)
			try
				open alias File_Location use doc prefs yes remap fonts no do auto picture import no
			end try
		end if
		
		set PSorPDF to button returned of (display dialog "Do you want to create single .ps files?" buttons {"Cancel", "PostScript Me Baby!"} default button "PostScript Me Baby!")
		if PSorPDF is "Cancel" then error "User canceled." number -128
		
		-- This line allows the user to specify a folder into which the PostScript and/or PDF files will be saved
		set DestFolder to (choose folder with prompt "Select a folder in which to the save the files.") as text
		
		tell document 1
			-- This section will parse the document name, to use when saving the PostScript files
			set DocName to my GetDocName(name)
			
			-- This script will error if a blank page is not printed
			tell print setup
				set BlankPages to include blank pages
				set include blank pages to true
			end tell
			
			-- This section will cycle through each page and save it as an individual PostScript file
			try
				set overwrite to null
				set curPage to page number of current page
				set pageCnt to count of pages
				repeat with i from 1 to count of pages
					-- This section will create the sequential number for the file
					set fileNum to ""
					repeat until (length of (fileNum as text)) = (length of (pageCnt as text))
						if fileNum = "" then
							set fileNum to i
						else
							set fileNum to "0" & fileNum
						end if
					end repeat
					-- This line will create the name for the file
					set FilePath to DestFolder & DocName & "_" & fileNum & ".ps"
					
					-- This following line will invoke a dialog for the first file whose name already exists
					-- This selection will be applied to subsequent files, so the dialog won't be display again
					set overwrite to my ifFileExists(FilePath, overwrite)
					
					-- The following section performs the save, if appropriate
					if overwrite is true or overwrite is null or overwrite is "temp" then
						if overwrite is true then
							-- This section will delete PS existing files with matching names
							try
								tell application "Finder" to delete alias FilePath
							end try
						end if
						print PostScript file FilePath
						if PSorPDF is "PostScript and PDF" then my DistillFile(FilePath)
					else if overwrite is "Quit" then
						-- The user cancelled from the duplicate file notification dialog
						-- This will end the script
						error "User canceled" number -128
					end if
				end repeat
				
				-- This line will show the page that was originally selected
				set current page to page curPage
				
				-- This will return the include blank pages property to its original state
				tell print setup
					set include blank pages to BlankPages
				end tell
				
				-- The following beep will provide feedback of script completion
				beep 2
			on error errmsg number errnum
				-- This will return the include blank pages property to its original state
				tell print setup
					set include blank pages to BlankPages
				end tell
				error errmsg number errnum
			end try
		end tell
	on error errmsg number errnum
		if errnum ? -128 then
			beep
			display dialog errmsg & " [" & errnum & "]" buttons {"OK"} default button 1 with icon stop
		end if
		-- For compatibility with non-US English operating systems
		return
	end try
end tell

--=================================== Handlers =========================================
-- Below are the handlers (subroutines) that are called from the above script
--===================================================================================

-- This handler will get the name of the QuarkXPress document, minus any qxd file extension
on GetDocName(DocName)
	set olddelims to AppleScript's text item delimiters
	set AppleScript's text item delimiters to "."
	if text item -1 of DocName = "qxd" then
		try
			set DocName to text items 1 thru -2 of DocName
			set AppleScript's text item delimiters to olddelims
		on error errmsg
			set AppleScript's text item delimiters to olddelims
			log errmsg
			return
		end try
	end if
	log DocName
	return DocName
end GetDocName

on ifFileExists(FilePath, bOverWrite)
	if bOverWrite is null then
		-- This section will check to see if a file exists, until a matching name has been found
		tell application "Finder"
			if exists alias FilePath then
				tell application "QuarkXPress"
					set overwrite to button returned of (display dialog "A file(s) with the same name already exists at this location. Saving will delete the existing file(s)." & return & return & ¬
						"Do you want to save anyway?" buttons {"Cancel", "Don't Save", "Save"} default button "Save" with icon caution)
				end tell
				if overwrite is "Save" then
					return true
				else if overwrite is "Don't Save" then
					return false
				else if overwrite is "Cancel" then
					return "Quit"
				end if
			else
				return null
			end if
		end tell
	else if bOverWrite is true then
		-- This section will keep creating files regardless of whether the names already exist
		return true
	else if bOverWrite is false or bOverWrite is "temp" then
		try
			tell application "Finder"
				if exists alias FilePath then
					-- This line will ensure that files whose names already exist are not created, 
					-- if you user previous chose to skip such file
					return false
				else
					-- This line will ensure that files whose names don't already exist will be created, 
					-- if the user previously chose to not overwrite existing files
					return "temp"
				end if
			end tell
		on error errmsg number errnum
			if errnum is not -128 then
				beep
				display dialog errmsg & " [" & errnum & "]" buttons {"OK"} default button 1 with icon stop
			end if
			return
		end try
	end if
end ifFileExists

I’m stripping out the distill a pdf option that you see referenced in the code…

…and no I’ve already checked out inDesign ‘:(’ and I’m not as impressed as everyone seems to be.