Setting Overprint to False causes MRAP

I’m trying to run this basic script, the first half I’ve run many times with no problem. But on a certain file is returns an MRAP error on certain lines. As for the second half, it’s untested (I’ve been trying to test it) and it returns an MRAP error on the indicated line every time.

Am I just missing something?


tell application "Adobe Illustrator"
	set thisdoc to current document
	tell thisdoc
		set visible of every layer to true
		set locked of every layer to false
		set locked of every page item to false --MRAP error
		delete (every path item whose guides is true)
		repeat with x from (count layers) to 1 by -1
			get page items of layer x --MRAP error
			if result is {} then
				delete layer x
			end if
		end repeat
		convert to paths (every text frame of thisdoc)
	end tell
end tell

set selection of thisdoc to {}
tell application "Adobe Illustrator"
	activate
	if (count of page items of thisdoc) is greater than 0 then
		set layerCount to count layers in current document
		repeat with l from 1 to layerCount
			set layerRef to layer l of thisdoc
			if (count page items of layer l of thisdoc) > 0 then
				set selected of (every page item of thisdoc whose container is layerRef) to true --MRAP error
			end if
		end repeat
	end if
	set selectedItems to selection of thisdoc
	set fill overprint of selection to false
	set stroke overprint of selection to false
end tell