Quark 7.2 "set contents" problem

I’m in the process of writing a script to automate this process:
“ Get text from Excel, in the form of blocks of Xpress Tags.
“ Paste into Quark for saving in the form of ASCII text
“ Open Quark template and import ASCII text
“ Loop through the pages saving each one as an EPS
(The EPSes are saved in a folder that Acrobat Distiller is watching, for final conversion into PDFs.)

I’m completely new to Applescript, but I’ve managed to put together a file that works perfectly with Quark 6.5. However, when I move to a different machine and try to run the script with Quark 7.2, I’m running into a problem with this block of script:


[script begins as below]
				--saves as Quark tags export file
				tell application "QuarkXPress 7.2"
					make new document
					tell page 1 of document 1
						set myBox to make text box at beginning with properties {bounds:{"3.875 cm", "4.962 cm", "8 cm", "18.742 cm"}}
						tell myBox
							set vertical justification to top justified
							set color to "none"
							set contents of story 1 to myText
							delete last character
							delete last character
							delete last character
							delete last character
						end tell
					end tell
[script continues as below]

When I run this block of script on its own, with myText defined at the start, it works perfectly: the text is pasted into a text box, last 4 characters deleted, all fine. When I run my whole script, however, the contents of story 1 emphatically refuse to be set to myText. It stays empty, no matter how I phrase the request. I’ve checked that myText contains the right information (it does) “ is there a limit on how large a text variable can be pasted into Quark? Is this a bug? What am I doing wrong?

Here’s the script in its entirety:


set DestFolder to (choose folder with prompt "Choose base destination folder. This should contain folders for Quark files & temp files.") as string
set EPSfolder to (choose folder with prompt "Choose folder for EPS output. This should be the same folder that Distiller is watching.") as string
tell application "QuarkXPress 7.2"
	activate
	display dialog "Please choose a Quark template" buttons {"OK"}
	set qxpBlank to (choose file of type {"XDOC", "XTMP", "XPRJ", "XPRT"})
end tell
tell application "Microsoft Excel"
	activate
	display dialog "Please choose an Excel file to use" buttons {"OK"}
	set FileLocation to (choose file)
	open FileLocation
	tell workbook 1
		tell worksheet 2
			set PlateNumber to value of cell "$A$1"
		end tell
		tell worksheet 1
			--finds first blank cell in col A
			set TargetRange to column 1
			set AfterCell to cell "$A$2"
			set FirstBlank to find TargetRange what "" after AfterCell look in values look at whole search direction search next
			-- deduces last cell with data
			set rowindex to ((first row index of FirstBlank) - 1)
			set LastCell to "$A$" & rowindex
			--gets range of cells needed for export
			set myRange to range ("$A$2:" & LastCell)
			--loops through cells in blocks of 100
			set UpperLimit to count cells in myRange
			repeat with c from 2 to (UpperLimit + 1) by 100
				set myText to ""
				--exports text as text block
				repeat with i from 0 to 99
					set curCell to "$A$" & (c + i)
					set myText to myText & value of cell curCell
				end repeat
				--saves as Quark tags export file
				tell application "QuarkXPress 7.2"
					make new document
					tell page 1 of document 1
						set myBox to make text box at beginning with properties {bounds:{"3.875 cm", "4.962 cm", "8 cm", "18.742 cm"}}
						tell myBox
							set vertical justification to top justified
							set color to "none"
							set contents of story 1 to myText
							return myText
							return contents of story 1
							delete last character
							delete last character
							delete last character
							delete last character
						end tell
					end tell
					tell document 1
						set filename to (PlateNumber & "_" & (c - 1) & "“" & (c + 98))
						set tmpFilePath to DestFolder & "TMP:" & filename
						set FilePath to DestFolder & "Quarks:" & filename & ".qxp"
						save every text of story 1 of myBox in tmpFilePath as "ASCII TEXT"
					end tell
					close document 1 saving no
					
					--imports into template
					open qxpBlank
					tell document 1
						set story 1 of text box 1 to alias tmpFilePath
						save in FilePath
						
						-- This section will cycle through the pages and save each as an EPS
						set overwrite to null
						set curPage to page number of current page
						set pageCnt to count of pages
						repeat with j from 1 to count of pages
							-- This section will create the sequential number for the file
							set fileNum to ""
							repeat until (length of (fileNum as text)) = (length of (pageCnt as text))
								if fileNum = "" then
									set fileNum to j
								else
									set fileNum to "0" & fileNum
								end if
								set POnum to word 3 of text box 4 of page j & " " & word 4 of text box 4 of page j --returns unique identity number for each EPS
							end repeat
							-- This line will create the name for the file
							set EPSfilename to EPSfolder & "In:" & POnum & ".eps"
							
							save page j in EPSfilename EPS format Standard EPS EPS data binary EPS scale 100 Output Setup "Composite CMYK and Spot" with transparent page
						end repeat
						
						-- Beep to indicate 100 EPS output
						beep 2
						
						
						close saving no
						
						
					end tell
				end tell
			end repeat
		end tell
	end tell
end tell