Place image in Quark pic box based on page number

Hi all,

I have a script that auto generates, places and sizes an picture box in Quark (7.31). It also names the box “boxName”

I am now trying to automate placing an image within that box (without the user having to select path or image file (otherwise, what would be the point??)). The image name will end with the page number + .EPS.

So far I have got the page number of the currently open Quark page. I now need to select the image that ends with this page number but am getting the error "“Can’t get file 1 of alias "pathtoimages:".”

Script so for is:-

set gFold to alias "Macintosh HD:restofpathtoimages"
tell application "QuarkXPress"
	activate
	tell document 1
		set pNo to name of current page
	end tell
end tell
get name of (1st file of gFold whose name contains pNo)

--tell application "QuarkXPress"
--	tell document 1
--		select (1st picture box whose name is "boxName")
--		
--		set image 1 to alias (1st file of (gFold) whose name contains pNo)
--	end tell
--end tell

Any help/advice much appreciated

well, it works with list folder and repeat loop …

set gFold to ((path to desktop) & "restofpathtoimages:") as text
tell application "QuarkXPress Passport"
	activate
	tell document 1
		set pNo to name of current page
	end tell
end tell
set MyList to list folder gFold
repeat with i from 1 to count of MyList
	set MyItem to item i of MyList
	if MyItem contains pNo then exit repeat
end repeat
tell application "QuarkXPress Passport"
	tell document 1
		select (1st picture box whose name is "boxName")
		
		set image 1 to alias (gFold & MyItem)
	end tell
end tell

Hans,

Thank you again. I should of thought of repeating through all files until we find the one that matches!

This works perfectly. Many thanks.