InDesign CS - place picture into existing frame

Hi All,

Working on a script to do a rough assemble of content into an InDesign file. Need to know the syntax to reference an existing picture box - Ie. on a master page. I have a basic script which can place an image on a page, how do I specify the frame that it goes to? and how a picture boxes differentiated? by geometry? by tag?

I’ve been to the adobe scripting site for InDesign - but it looks like the more complicated scripting is done with Javascript. Is Javascript a better option for InDesign automation? Adobe also produces an Applescripting guide for InDesign, which is very useful as it has lots of sample scripting, this has chapters on text format but almost nothing on working with images.

Thanks in Advance.

Matt.

Model: G4 933 1GB/60/SD
AppleScript: 1.9.3
Browser: Firefox 2.0.0.12
Operating System: Mac OS X (10.3.9)

Question also placed of Adobe Forums http://www.adobeforums.com

Solution from Shane Stanley - Thanks Shane :slight_smile:

tell application "Finder"
	-- Select source folder
	set srcfolder to choose folder with prompt "Select a folder of images to place in Indesign"
	
	-- Count the number of images to place
	set imageqty to count every item of folder srcfolder
	display dialog imageqty & " images to place" as string giving up after 2
	
	-- Create list of images to place
	set PicList to every item of folder srcfolder
	
end tell


set picboxnum to 1

-- Indesign construction - assumes sufficient frames on page
tell application "InDesign CS"
	activate
	tell document 1
		repeat with thisitem in PicList
			-- display dialog thisitem as string
			place thisitem as alias on rectangle picboxnum of page 1
			--  with properties {"centre content"}
			select rectangle picboxnum
			
			-- Sub routine to get the image to centre - can't nut this out in the "place" command
			tell application "System Events"
				tell process "indesign CS"
					set frontmost to true
					keystroke "e" using shift down & command down
				end tell
			end tell
			
			-- Thanks Shane Stanley Adobe Forums
			set picboxnum to (picboxnum + 1)
		end repeat
	end tell
end tell

The solution being adding the on rectangle reference.

Now, I just need to sort out how I can release a frame from a master page in AS to allow an image to be placed. (By default master page items have to be “shift-command-clicked” to allow access.

Matt.

The fastest and easiest way to find a given frame in InDesign is “Script Labels”. This is a very useful addition Adobe add to InDesign (I can’t remember if CS has it but I know CS2 and CS3 does). Basically “Script Labels” allows you to make an object reference to a frame or anything in InDesign by name.

Simple example

tell application "Adobe InDesign CS3"
	tell document 1
		make new text frame with properties {label:"dude"}
	end tell
end tell

Also to unlock or release a master page item is not too bad. Just remember you must tell InDesign what master page the item is on and what page you want to unlock it on.

tell application "Adobe InDesign CS3"
	tell document 1
		override every page item of master spread myMasterPage destination page last page
	end tell
end tell

Thanks Neweller.

Yes, CS does include a “script label” palette. Hadn’t considered actually using AS to label (tag) the objects - That makes sense.

Override command works a treat.

Matt.