Quark 6.52 - delete all guides?

I am trying to create a script to delete all the existing guides on a given Quark project. The script is based on one I wrote which creates guides in specific places where I want them. The original script works fine. The new one doesn’t. FYI: We work with files which are created by people outside our organization, which frequently have a lot of useless guides in place. I want to delete all of these, then run my other script to create the guides I need. I’ve got the second part working. Using the code below, the commands to bring the guides to from , to unhide, etc., work fine. Only the delete part doesn’t work. Note: The “tell current spread” portion of the script acts like it is being skipped - there is no notice of it in the event log. I expected that putting it in a try statement would provide some feedback if it failed. If anyone can help me with this, I would appreciate it.

(* This script written by Jonathan Gardner, © Gardner Designs, 2008. *)

tell application "QuarkXPress"
	activate
	if (exists project 1) is false then
		beep
		activate
		display dialog "A QuarkXPress project must be open for this script to work." buttons "OK!" default button 1 with icon 2
	else
		try
			tell document 1
				set guides showing to true
				set guides in front to true
				set lock guides to false
				set horizontal guides to deletable
				set vertical guides to deletable
				--------
				tell current spread
					ignoring application responses
						try
							delete every vertical guide
							delete every horizontal guide
						on error the error_message number the error_number
							display dialog "The delete attempt failed -" & the error_number & ". " & the error_message buttons {"Cancel"} default button 1
						end try
					end ignoring
				end tell
				--------
			end tell
		end try
		with timeout of 11 seconds
			activate
			display dialog "Your guides have been deleted." buttons "Thanks!" default button 1 giving up after 10
		end timeout
	end if
end tell

Guides can contained by both spreads and pages depending on where they were dragged to in the GUI have you tried both?

tell application "QuarkXPress"
	activate
	tell document 1
		repeat with i from 1 to count of spreads
			tell spread i
				delete every vertical guide
				delete every horizontal guide
			end tell
		end repeat
		repeat with i from 1 to count of pages
			tell page i
				delete every vertical guide
				delete every horizontal guide
			end tell
		end repeat
	end tell
end tell

Thanks, Mark. That worked fine. Two things were wrong in my script. I found that the “set to… deletable” hosed everything. If I take this out, I am in business. Wrong use of terminology, I suppose. Not a big deal, it probably won’t be needed anyway. The second was using “spread” and not also “page”. Even if my script had worked, it would only have deleted the guides from the pasteboard, not the page.

Until now I never quite understood Quark’s use of “document”, “spread” and “page”. Your example helped make that little light bulb go off over my head. I appreciate it!

-Jon

Thank you Mark67!

I had been using the following script, but it only removed page guides:

tell application "QuarkXPress Passport"
	tell document 1
		repeat with i from 1 to count of pages
			tell page i
				if every vertical guide exists then
					delete every vertical guide
				end if
				if every horizontal guide exists then
					delete every horizontal guide
				end if
			end tell --page
		end repeat
		set properties to {horizontal measure:inches, vertical measure:inches, trapping method:absolute trap}
	end tell --document
end tell --application