Set new and/or change current page size in Adobe InDesign

I am returning to KM after several years. During that hiatus I set up 30+ apple scripts to either open and create a file at certain size or change the size of the currently open document. These were eventually connected to my Stream Deck.

When INDD 2024 came out the scripts stopped working. The script creates a 8.5" x 11" document regardless of the instruction within the script and returns the error "data out of range". I attempted over the last several months to fix the scripts and nothing has worked.

Now that I've come back to KM, I would like to poll your experience for the "best practice" to recreating these with KM.

Should I keep trying to correct these scripts to employ the "execute an apple script" macro?
I did create a successful macro with "activate application" > "type a keystroke" > "insert text by typing" and it worked great however doesn't seem the most efficient.

I send files to numerous print publications at all different sizes and the scripts saved me so much time.

This is the base script from which all the others were created.

-- Activate the Adobe InDesign Application
tell application "Adobe InDesign 2024"
	activate
end tell


tell application "Adobe InDesign 2024"
	-- Create a new document
	set newDocument to make new document
	
	tell newDocument
		tell document preferences
			-- Set page size in points (1 inch = 72 points)
			set page width to 585
			set page height to 783
			
			-- Set facing pages to false
			set facing pages to false
			
			-- Set bleed (all values in points)
			set document bleed top offset to 9
			set document bleed bottom offset to 9
			set document bleed inside or left offset to 9
			set document bleed outside or right offset to 9
			set document bleed uniform size to true
		end tell
		
		-- Set the measurement units to inches
		tell view preferences
			set horizontal measurement units to inches
			set vertical measurement units to inches
		end tell
	end tell
end tell

This has been my only successful attempt with KM.

Thank you in advance.

Regarding the AppleScript, InDesign has a parameter that changes the default measurement unit used when performing functions via a script. In your case, I think the default has been changed to inches, causing InDesign to attempt to create a document measuring 585 x 783 inches, which it cannot do (maximum size is 216"). You need to change the default back to points.

Try to add set measurement unit of script preferences to points after the second tell application "Adobe InDesign 2024", like this:

-- Activate the Adobe InDesign Application
tell application "Adobe InDesign 2024"
	activate
end tell


tell application "Adobe InDesign 2024"
	
	-- Change scripting measurement units to points
	set measurement unit of script preferences to points
	
	-- Create a new document
	set newDocument to make new document
	
	tell newDocument
		tell document preferences
			-- Set page size in points (1 inch = 72 points)
			set page width to 585
			set page height to 783
			
			-- Set facing pages to false
			set facing pages to false
			
			-- Set bleed (all values in points)
			set document bleed top offset to 9
			set document bleed bottom offset to 9
			set document bleed inside or left offset to 9
			set document bleed outside or right offset to 9
			set document bleed uniform size to true
		end tell
		
		-- Set the measurement units to inches
		tell view preferences
			set horizontal measurement units to inches
			set vertical measurement units to inches
		end tell
	end tell
end tell

Thank you for the reply. This worked. :clap:

I had previously altered the unit preferences in INDD and how the script set the measurement however was unsuccessful. Maybe I never had the right combination and I have replaced both my Mac Studio and MBP since that time. Wonder if there was preference conflict? I say that because our prepress department had to uninstall/re-install all Creative Cloud apps due to a script conflict with our AGFA equipment.

Off to alter all my scripts. Thank you again.