InDesign CS5.5 can't place images

I recently upgraded a few users to CS5.5 from CS4 and found out an applescript running in Filemaker no longer works with InDesign 5.5.
Any help is greatly appreciated.
Thanks,
Mike

Original Script below: ( I only changed the line "tell application “Adobe InDesign CS4” to be "tell application “Adobe InDesign CS5.5”)


property imgNotFound : "Client_Images_01:zPageBuilder:Bugs:ImageNotFound.eps" -- MAKE FILE NOT FOUND EPS


tell application "Adobe InDesign CS4"
	tell document 1
		if not (layer "Images" exists) then make layer with properties {name:"Images"}
		if not (layer "Hide" exists) then make layer with properties {name:"Hide"}
	end tell
end tell

tell application "FileMaker Pro Advanced"
	tell current record
		
		set pBox to "p" & (cell "gt_Position" as string) as string
		set tBox to "t" & (cell "gt_Position" as string) as string
		set imgFileName1 to cell "gt_Place_Image1" as string
		set imgFileName2 to cell "gt_Place_Image2" as string
		set imgFileName3 to cell "gt_Place_Image3" as string
		
		if imgFileName1 is not "" then
			set staggerAmount to cell "gt_Place_Image_Stagger" as real
			set staggerAmount to (staggerAmount + 0.25) as real
			set cell "gt_Place_Image_Stagger" to staggerAmount
			set imgFilePath1 to getFilePath(imgFileName1) of me
			if imgFilePath1 is not "" then placeImage(pBox, imgFilePath1, "1", staggerAmount, tBox) of me
		end if
		
		if imgFileName2 is not "" then
			set staggerAmount to cell "gt_Place_Image_Stagger" as real
			set staggerAmount to (staggerAmount + 0.25) as real
			set imgFilePath2 to getFilePath(imgFileName2) of me
			if imgFilePath2 is not "" then placeImage(pBox, imgFilePath2, "2", staggerAmount, tBox) of me
		end if
		
		if imgFileName3 is not "" then
			set staggerAmount to cell "gt_Place_Image_Stagger" as real
			set staggerAmount to (staggerAmount + 0.25) as real
			set imgFilePath3 to getFilePath(imgFileName3) of me
			if imgFilePath3 is not "" then placeImage(pBox, imgFilePath3, "3", staggerAmount, tBox) of me
		end if
		
		
	end tell
end tell

--PLACE IN INDESIGN DOC
on placeImage(pBox, imgFilePath, imgCount, staggerAmount, tBox)
tell application "Adobe InDesign CS4"
		activate
		tell document 1
			
			set pBoxRef to page item pBox
			move page item pBox to layer "Hide"
			
			set newBox to duplicate pBoxRef
			set label of newBox to (pBox & "_" & imgCount as string)
			place imgFilePath on newBox
			fit item 1 of newBox given proportionally
			fit item 1 of newBox given center content
			move newBox to layer "Images"
			
			set theBounds to geometric bounds of pBox as list
			
			try
				set bnd1 to item 1 of theBounds as real
				set bnd2 to item 2 of theBounds as real
				set bnd3 to item 3 of theBounds as real
				set bnd4 to item 4 of theBounds as real
			on error
				set bnd1 to 0
				set bnd2 to 0
				set bnd3 to 0
				set bnd4 to 0
			end try
			
			if bnd1 ≠ 0 then
				set newBnd1 to bnd1 + staggerAmount
				set newBnd2 to bnd2 + staggerAmount
				set newBnd3 to bnd3 + staggerAmount
				set newBnd4 to bnd4 + staggerAmount
				
				set newBounds to {newBnd1, newBnd2, newBnd3, newBnd4} as list
				
				set geometric bounds of page item pBox to newBounds
			end if
			
		end tell
	end tell
end placeImage

--GET IMAGE PATH
on getFilePath(imgFileName)
	
	set imgFilePath to "Sears_Images_01:"
	set imgFolderName to characters 2 thru -1 of imgFileName as string
	set imgFolderName to ((round (imgFolderName / 200) rounding down) as string) * 200 as string
	set imgFolderName to characters -1 thru -6 of ("000000" & imgFolderName as string) as string
	
	set imgFilePath to imgFilePath & "s" & imgFolderName & ":" & imgFileName & ".eps" as string
	
	tell application "Finder"
		if file imgFilePath exists then
			return imgFilePath
		else if file imgNotFound exists then
			return imgNotFound
		else
			return ""
		end if
	end tell
	
end getFilePath

gidday mike13a

something like this maybe

tell application "Adobe InDesign CS5.5"
	try
		place (imgFilePath) as alias on newBox
	end try
end tell

I get an error of “Adobe InDesign CS5.5 got an error: Can’t get page item “p001” of document 1.”

there maybe other problems in your code after updating to cs5.5, as for the place command this works fine here

set imgFilePath to "PATH TO IMAGE"

tell application "Adobe InDesign CS5.5"
	set newBox to rectangle 1 of active document
	try
		place (imgFilePath) as alias on newBox
	end try
end tell

THanks Budgie, that places a new image onto a page at the far right edge of the pasteboard.
Gets me started for placing. Now How do call a specific box by it’s script tag?

Have you tried versioning the script as is to run in 5.5 ? You can set the version property of the app’s script prefs then wrap the script in a using terms of block. May get you by short term. You will need both versions to compile the code though.

try something like this for placing an image into a tagged rectangle

set imgFilePath to "PATH TO FILE"

tell application "Adobe InDesign CS5.5"
	activate
	tell document 1
		set theRects to every item of all page items whose class is rectangle and label is "IMAGE"
		repeat with i from 1 to count of theRects
			set newBox to item i of theRects
			try
				place imgFilePath as alias on newBox
			end try
		end repeat
	end tell
end tell

@ Mark67
Not sure what you mean by versioning the script. as in “Using terms from InDesign CS4”?

Not sure if that would work.

@Budgie,
Let me take that for a spin and I’ll let you know how that works. Just reading it though, it sounds like that is the right track.
I’ll let you know How I make out with it later today.
Mike

See script versioning in this AppleScript topic it’s a feature of the app.
It applies to all 3 supported scripting languages.

http://www.mactech.com/articles/mactech/Vol.24/24.02/AdobeCS3andAppleScript/index.html

Wow! That may be the easiest method yet to accomplish what I need. Get the users working until I can rewrite the script for CS 5.5
I’ll try that as a stop gap measure.
Thanks!

You can learn all the new stuff at your leisure. It’s Friday so go out. :wink:

So I had errors trying the “Using terms” method, but I did finally get it to work using the following statements. (Script clipped)


tell application "Adobe InDesign CS5.5"
	activate
	tell document 1
		set pBoxRef to every page item whose label is pBox
		
		move pBoxRef to layer "Hide"
		
		set newBox to duplicate pBoxRef
		set label of newBox to (pBox & "_" & imgCount as string)
		place file imgFilePath on newBox
		fit item 1 of newBox given proportionally
		fit item 1 of newBox given center content
		move newBox to layer "Images"
	end tell
end tell

Thanks.
Working on text frames now…