Applescript working in Desktop and not working in Script Folder

I am upgraded to macOS mojave version 10.14 to iMAC macOS sonoma version 14.5
The below script worked in macOS mojave version 10.14 and Script Editor version 2.11

tell application "QuarkXPress 2017"
	tell document 1
		set item spread coords to true
		-- set guides showing to true
		set oldPageRuleOrigin to page rule origin
		set oldCoords to item spread coords
		set oldHMeasure to horizontal measure
		set oldVMeasure to vertical measure
		set properties to {horizontal measure:points, vertical measure:points, page rule origin:{0, 0}}
		set PageWidth to (width of bounds of current page)
		set PageWidth to text 1 thru -4 of PageWidth as real
		set sel to the selection
		set SelectedText to sel as string

		if SelectedText ≠ "null" and SelectedText ≠ "" then
			set {T, L, B, R} to bounds of current box as list
			set BoxWidth to (width of bounds of current box)
			set BoxWidth to text 1 thru -4 of BoxWidth as real
			set L to coerce (L) to real
			set startposition to horizontal offset of first character of selection
			set startposition to text 1 thru -4 of startposition as real
			set endposition to horizontal offset of last character of selection
			set endposition to text 1 thru -4 of endposition as real
			set endcharwidth to width of last character of selection
			set endcharwidth to text 1 thru -4 of endcharwidth as real
			
			
			if BoxWidth > PageWidth then
				
				tell current page
					set startguideposition to (L + startposition)
					set endguideposition to (L + endposition + endcharwidth)
					make vertical guide at beginning with properties {position:startguideposition}
					make vertical guide at beginning with properties {position:endguideposition}
				end tell
				
				
			else if BoxWidth ≤ PageWidth then
				
				tell current page
					set startguideposition to (L + startposition)
					set endguideposition to (L + endposition + endcharwidth)
					make vertical guide at beginning with properties {position:startguideposition}
					make vertical guide at beginning with properties {position:endguideposition}
				end tell
				
			end if
			set page rule origin to oldPageRuleOrigin -- restore ruler origin
			set item spread coords to oldCoords -- restore ruler system
			set horizontal measure to oldHMeasure
			set vertical measure to oldVMeasure
			set item spread coords to false
		else
			display dialog " Please SELECT your text in the Quark Document" & return buttons {"OK", "Cancel"} with title "Make Guides" default button 1
			
		end if
		
	end tell
	--display dialog "Guide Creation has been completed."
	
end tell

and converted as below and not working in iMAC macOS sonoma version 14.5 and Script Editor version 2.11

tell application "QuarkXPress 2023"
	tell document 1
		set «class ITSC» to true
		-- set guides showing to true
		set oldPageRuleOrigin to «class PGOR»
		set oldCoords to «class ITSC»
		set oldHMeasure to «class HMEA»
		set oldVMeasure to «class VMEA»
		set «class qpro» to {«class HMEA»:«constant measUPNT», «class VMEA»:«constant measUPNT», «class PGOR»:{0, 0}}
		set PageWidth to («class widt» of bounds of «class CUPG»)
		set PageWidth to text 1 thru -4 of PageWidth as real
		set sel to the selection
		set SelectedText to sel as string

		if SelectedText ≠ "null" and SelectedText ≠ "" then
			set {T, L, B, R} to bounds of «class CUBX» as list
			set BoxWidth to («class widt» of bounds of «class CUBX»)
			set BoxWidth to text 1 thru -4 of BoxWidth as real
			set L to «event XPRSCOER» (L) given «class rtyp»:real
			set startposition to «class hzof» of first character of selection
			set startposition to text 1 thru -4 of startposition as real
			set endposition to «class hzof» of last character of selection
			set endposition to text 1 thru -4 of endposition as real
			set endcharwidth to «class widt» of last character of selection
			set endcharwidth to text 1 thru -4 of endcharwidth as real
			
			
			if BoxWidth > PageWidth then
				
				tell «class CUPG»
					set startguideposition to (L + startposition)
					set endguideposition to (L + endposition + endcharwidth)
					--make «class VGDE» at beginning with properties {«class ppos»:startguideposition}
					make «class VGDE» at beginning with properties {«class ppos»:endguideposition}
				end tell
				
				
			else if BoxWidth ≤ PageWidth then
				
				tell «class CUPG»
					set startguideposition to (L + startposition)
					set endguideposition to (L + endposition + endcharwidth)
					make «class VGDE» at beginning with properties {«class ppos»:startguideposition}
					make «class VGDE» at beginning with properties {«class ppos»:endguideposition}
				end tell
				
			end if
			set «class PGOR» to oldPageRuleOrigin -- restore ruler origin
			set «class ITSC» to oldCoords -- restore ruler system
			set «class HMEA» to oldHMeasure
			set «class VMEA» to oldVMeasure
			set «class ITSC» to false
		else
			display dialog " Please SELECT your text in the Quark Document" & return buttons {"OK", "Cancel"} with title "Make Guides" default button 1
			
		end if
		
	end tell
	--display dialog "Guide Creation has been completed."
	
end tell

(Markdown backtick tags added to the posted code by NG for proper display on MacScripter. See the MarkDown Reference here.)