Delete Master page

How do I delete an specific Master page on InDesign. The code below delete all unused master pages but except one which is in use but I just want to delete it

set moreMasters to {}
		tell application "Adobe InDesign CS4"
			repeat with i from 1 to count of documents
				tell document i
					set allMasters to every master spread
					set theMasters to applied master of every page
					repeat with x in theMasters
						set end of moreMasters to applied master of x
					end repeat
					set theMasters to theMasters & moreMasters
					repeat with x in allMasters
						if x is not in theMasters then delete x
					end repeat
					if exists (master spread whose name is "Z-OMX Master") then delete
				end tell
			end repeat
		end tell

Hi,

logically it’s


tell application "Adobe InDesign CS4"
	tell active document
		if exists (master spread "Z-OMX Master") and (count master spreads) > 1 then delete master spread "Z-OMX Master"
	end tell
end tell

Thanks Stefan but that is giving me an error

error “Can’t make «class mspr» id 3109 of document "WOW_134.indd" of application "Adobe InDesign CS4" into type boolean.” number -1700 from «class mspr» id 3109 of document “WOW_134.indd” to boolean

forgot a pair of parentheses


tell application "Adobe InDesign CS4"
	tell active document
		if (exists (master spread "Z-OMX Master")) and (count master spreads) > 1 then delete master spread "Z-OMX Master"
	end tell
end tell

Stefan,
A missing parenthesis causing this error. These are things I tried to figure it out & I can’t. Since you are an experience scripter how did you realize was a parenthesis? I heard a program called Script Debugger that may help me to catch this errors. Do you recommended me to buy it?

“Can’t make . into boolean” is always an indicator that one of the expressions could not be evaluated.
Script Debugger is a extraordinary tool for debugging code by watching variables and trace the code step by step,
but no scripting developer environment can display compiler warnings for an runtime error

:smiley: thanxs

How do I apply [None] master to all Master pages? The idea is to delete all unused master pages but the one that is used apply [None] master. I tried this line & Im getting an error:
Invalid value for set property ‘applied master’. Expected master spread or nothing, but received nothing." number 30477

set moreMasters to {}
			set allMasters to every master spread
			set theMasters to applied master of every page
			repeat with x in theMasters
				set end of moreMasters to applied master of x
			end repeat
			set theMasters to theMasters & moreMasters
			repeat with x in allMasters
				if x is not in theMasters then delete x
			end repeat
			set applied master of spread 1 to master spread "[None]"
			--if x is in theMasters then applied master of master spread 1 to "[None]"