Place image in InDesign ... HOW?!

I’m going nuts now.

I’ve been trying to place a simple tif file in an existing frame in InDesign CS5.5. Simple, no? No.

Here’s the script:

set titlePage to page 1 of active document
	
	tell titlePage
		-- Create logo frame
		set theLogoFrame to make rectangle with properties {geometric bounds:{"157.35 mm", "65.181 mm", "172.33 mm", "77.819 mm"}, label:"logoFrame", stroke weight:0}
		set theBoilerPlateFrame to make rectangle with properties {geometric bounds:{"175.435 mm", "43.865 mm", "183.567 mm", "99.135 mm"}, label:"boilerPlateFrame", stroke weight:0}
		tell theLogoFrame
			place titlePageLogo
		end tell
		
		tell theBoilerPlateFrame
			place titleBoilerPlate
		end tell
	end tell

But this gives the following error:
Adobe InDesign CS5.5 got an error: “~/Desktop/V logo (cmyk red) TRANS.tif” doesn’t understand the place message.

So, I thought it looked like the script was trying to pass the place command to the image - hence it doesn’t understand. So I tried tweaking the place part…

tell theLogoFrame
			place titlePageLogo as alias
		end tell

Hoping the ‘as alias’ would fix it. Now, however, I get the following error:
File ~/Desktop/V logo (cmyk red) TRANS.tif wasn’t found.

It is on the Desktop and it does exist. I even dragged the file into the script to ensure that I hadn’t garbled a character somewhere.

Any ideas why I get the error? I’ve tried a variety of different place methods, after trawling through the .sdef, but nothing works.

Forgot to say … I had previously defined the following variables (specific path details are omitted for security reasons):

set assetSourceFolder to "... the path to the folder enclosing the assets ..."
	set titlePageLogo to (assetSourceFolder) & "V logo (cmyk red) TRANS.tif"
	set titleBoilerPlate to "... the path to another asset ..."

Sorry.

Here’s the essence of what I use in CS4:

set photoFP to “HD:images:XYZ11:sample.TIF”

tell application “Adobe InDesign CS4”
tell active document
tell page 1
place file photoFP on page item “PersonPhoto” – label of rectangle; may need to change in CS5+
end tell
end tell
end tell

give this a shot Kev

set myNameFile to "path to file"
tell application "Adobe InDesign CS5"
	activate
	set myDoc to active document
	tell page 1 of myDoc
		set myRectangle to make rectangle with properties {geometric bounds:{10, 158, 60, 198}}
		try
			place alias (myNameFile) on myRectangle
			fit rectangle 1 given center content
		on error
			-- do your stuff
		end try
	end tell
end tell

Budgie, that worked fine.

I had to change my ‘/’ characters to ‘:’ in the file path variables, but that did it. Now I need to figure out how to scale and position the content to fit.

Many thanks - I was pulling my hair out!

cool, glad that helped, try something like this for scaling

set myNameFile to "PATH TO FILE"
tell application "Adobe InDesign CS5"
	activate
	set myDoc to active document
	tell page 1 of myDoc
		set myRectangle to make rectangle with properties {geometric bounds:{10, 40, 60, 90}}
		try
			place alias (myNameFile) on myRectangle
			fit rectangle 1 given center content
		on error
			-- do your stuff
		end try
	end tell
	
	tell document 1
		set transform reference point of layout window 1 to center anchor
		--set theImages to all page items -- scales rectangle
		set theImages to all graphics -- scales the graphic only
		repeat with i from 1 to count of theImages
			set MyImage to item i of theImages
			set absolute horizontal scale of MyImage to 25
			set absolute vertical scale of MyImage to 25
		end repeat
	end tell
end tell

fit image given fill proportionally – Will fill your frame without image distortion
fit image given center content – Centers the content either V or H dependent on fill direction

That’s exactly what I needed … thank you all!