Automating placing EPS files into Quark template -- Making overheads

Very green applescripter, trying to start off in Applescript with some basic tasks…

Making overhead transparencies, each having within a large EPS image and an accompanying figure title.

So… I have a QuarkXPress template in which I’m trying to place a folder’s worth of EPS files. I’d also like to import a list of titles from an Excel sheet for these, but first things first…

So far nothing really happens and I’m getting the AppleScript Error: “QuarkXPress got an error: An error of type 180 has occurred.”

Any help appreciated…

set theQuarkDoc to choose file with prompt "Select a Quark Template"

tell application "Finder"
	set epsFolder to folder (choose folder with prompt "Select a folder containing your EPS Files") as string
	set fileList to list folder epsFolder
end tell

set y to 1

repeat with x from 1 to the length of fileList
	set currentEPS to item x of fileList
	set currentEPSref to (epsFolder & currentEPS) as alias
	
	tell application "QuarkXPress"
		open theQuarkDoc
		tell document 1
			tell picture box 1 of page y
				set contents of image 1 to currentEPSref
				set angle of image 1 to "90"
				set bounds of image 1 to proportional fit
				--set offset of image 1 to {"0", "0"}
			end tell
		end tell
		set y to y + 1
	end tell
end repeat

Using your posted code and making two small changes (see commented areas) works fine for me in Quark 6.5

set theQuarkDoc to choose file with prompt "Select a Quark Template"

--**REMOVE LINE BELOW THIS ONE
--tell application "Finder"
set epsFolder to (choose folder with prompt "Select a folder containing your EPS Files") as string
--**EDITED LINE BELOW THIS ONE
set FileList to list folder epsFolder without invisibles
--**REMOVE LINE BELOW THIS ONE
--end tell

set y to 1

repeat with x from 1 to the length of FileList
	set currentEPS to item x of FileList
	set currentEPSref to (epsFolder & currentEPS) as alias
	
	tell application "QuarkXPress"
		open theQuarkDoc
		tell document 1
			tell picture box 1 of page y
				set contents of image 1 to currentEPSref
				set angle of image 1 to "90"
				set bounds of image 1 to proportional fit
				--set offset of image 1 to {"0", "0"}
			end tell
			--**ADD LINE BELOW THIS ONE
			make new page at end
		end tell
		set y to y + 1
		
	end tell
end repeat

Here’s some code that will construct a new document and automate the number of pages to the amount of images in a folder, it also has a text box that is the files name which could be addapted to your slide title. Some of this may be of use to you.

set TodaysDate to do shell script "date \"+%d-%m-%y\""
tell application "QuarkXPress"
	activate
	set thepath to (choose folder with prompt "Choose Folders") as text
	set ItemList to list folder thepath without invisibles
	set FileList to {}
	tell default document 1
		set page height to "210 mm"
		set page width to "297 mm"
		set left margin to "20 mm"
		set right margin to "20 mm"
		set top margin to "20 mm"
		set bottom margin to "20 mm"
		set automatic text box to false
		set guides showing to true
		set guides in front to true
		set horizontal measure to millimeters
		set vertical measure to millimeters
	end tell
	make document at beginning
	tell document 1
		set bounds to {22, 50, 1150, 200}
		set view scale to 35
	end tell
	tell spread 1 of master document 1
		make picture box at beginning with properties ¬
			{bounds:{"20 mm", "20 mm", "170 mm", "277 mm"}, color:"None"}
	end tell
	tell spread 1 of master document 1
		make text box at beginning with properties ¬
			{bounds:{"175 mm", "20 mm", "190 mm", "277 mm"}}
		tell text box 1
			set color to "none"
		end tell
		tell story 1 of text box 1
			set contents of it to (item 1 of ItemList & return & TodaysDate) as text
			set font to "Frutiger 65 Bold"
			set size to 14
			set leading to 20
			set justification to centered
		end tell
	end tell
	set ThisItem to item 1 of ItemList
	try
		tell page 1 of document 1
			set image 1 of picture box 1 to alias (thepath & (ThisItem))
			set bounds of image 1 of picture box 1 to proportional fit
		end tell
	on error
		beep
	end try
	repeat with X from 2 to count of ItemList
		set ThisItem to item X of ItemList
		tell document 1
			make new page at end
			set page X to current page
			try
				set image 1 of picture box X to alias (thepath & (ThisItem))
				set bounds of image 1 of picture box X to proportional fit
				tell story 1 of text box 1 of page X
					set contents of it to (item X of ItemList & return & TodaysDate) as text
				end tell
			on error
				beep
			end try
		end tell
	end repeat
	set guides showing of document 1 to false
	tell print setup of document 1
		set printer type to "Xerox DocuColor3535"
		set paper size to "A4 SEF"
		set orientation to landscape
		set page position to center position
		set print colors to composite CMYK
		set print spreads to false
		set reduce or enlarge to "100%"
		set registration marks to off
	end tell
	print document 1 copies 2
	close document 1 saving no
end tell

Wow, quite cool! Thanks!

Would there be a way to suck the titles an excel sheet? I’m working from an excel sheet that gives me the EPS file name, the name of what’s contained in the file (e.g. Figure 3.4) and a small blurb that functions as a subtitle… I was thinking of having my script troll the columns in a similar way to how the folders are mined above, but is that the best way? And should this happen after all the pages are created, or during?

Model: iMac G5
Browser: Safari 312.6
Operating System: Mac OS X (10.3.9)

I won’t be able to help with that part but would think you need to save your excel cells as lists somehow then you could use item X of ItemListA & X of ItemListB etc. Someone else maybe able to assist you further with that part. Using default doc and master doc is cool though no need to have a template all depends on what needs setting up.