Quark error code -10006

Hi, I have been working on this script for a bit. I almost have it completed, my hang up is at the end of the script. I receive the error code from Quark at the end of the script.

error “QuarkXPress got an error: Can’t set story1 of text box 1 of document "file.qxp" to "EN76254".” number -10006 from story1 of text box 1 of document “file.qxp”.

I have also included the full script, so if anybody can see my error can notify me where I have gone wrong. Thanks.

tell application “QuarkXPress”
activate
–error checking
set checkVolumes to (list disks)
set textPath to {“Public:Customer Artwork:CUST LIBRARY:ENVTXT2:”}
set statList to {“A- BrushScript”, “B- FranklinGothic”, “C- Souvenir”, “D- UniversityRoman”, “E- Helvetica”, “F- KauflinKoffee”, “G- Optimum”, “H- CopperPlate”}
set stockList to {“CopperPlate”, “Helvetica”, “NewBaskerville”}

if (exists document 1) is true then
	try
		set workpath to ("" & (path to current user folder)) & "Desktop:" as text
		tell application "QuarkXPress"
			set filepath to workpath & "file.qxp"
			
			save document 1 in filepath version 80
			close document 1 saving no
			delay 2
			
			tell application "QuarkXPress" to open ((path to desktop) & "file.qxp")
			do shell script "read & write" password "bibbero" with administrator privileges
		end tell
	end try
end if


delay 5
tell application "QuarkXPress"
	
	display dialog "Enter Customer Number" with default answer
	set custNumber to text returned of result
	
	tell document 1
		
		set targetBox to object reference of (text box 1 whose selected is true)
		set targetBox2 to object reference of (text box 2 whose selected is true)
	end tell
	
	
end tell




if (exists document 1) then
	set targetPage to targetBox
	
	set custBug to (every text box whose name is "ENVBUG") of page 1 of document 1
	set targetBug to (every text box whose name is "ADDR") of page 1 of document 1
	
	
	
end if

end tell

–select styles
beep
display dialog " Stationery or Stock Styles?" buttons {“Stationery”, “Stock”}
if button returned of the result is “Stationery” then
set stationeryStyles to item 1 of (choose from list statList with prompt “Stationery” without multiple selections allowed)
else
set stockChoice to item 1 of (choose from list stockList with prompt "Stock " without multiple selections allowed)

end if

–format page
set importStyles to true
set custBug to “EN” & custNumber
set textFormat to textPath & item 1 as text
set story1 of targetBox to {custBug} as text
set story1 of targetBox2 to {textPath} & item 1 as text

I know nothing of Quark, but I don’t think the code you posted will produce the error you are getting. I also think it will not compile, as there seems to be Quark code outside the Quark tell block.
format page and select style are never executed, as they are not in a tell application “QuarkXPress” block.

There are nested tell blocks. They may confuse both QuarkXPress and readers of your post…:wink:

There are two commands that do not belong to Quark.
The 1st one is list disks, and it does nothing; the list is never used.
The 2nd one is do shell script.
Commands not belonging to the application you are ‘telling’ should be moved outside the tell block, if possible. You can end tell, execute the command, and continue with tell….
Also, these are ‘scripting additions’, commands defined in an osax - Standard Additions, in this case.
Having them inside a tell block will not usually break a script, only slow it down. Here’s proof:

tell application "TextEdit"
	list disks
		--> error number -1708
	«event ascrgdut»
		--> error number -1708
	list disks
		--> error number -10004
end tell
tell current application
	list disks
		--> {"all of my connected drives"}
end tell

This is from the Events pane of the Script Editor, after telling TextEdit to lists disks. What you are seeing is ‘redirection’; AppleScript trying to find an entity that can execute the command. As you can see, it finds “current application” with the 4th attempt. The 3 other messages (events) were unsuccesful, but took time to send. Solution: tell me to .

Caution: your variable statList is also a keyword of the Satimage osax. The script will fail when the osax is present.

And please use the available tags. Scripts are much more readable when formatted as such.

Hello Alastor. First off, thank you for your input, it is much appreciated. I apologize for any confusion that I may have caused with my formatting of my script, I am still learning about AppleScripting and any assistance is great. I have made some of the changes you have suggested but I am still having the same error code pop up. The research that I have done seems to indicate the error code being a permissions issue, but I verified that I have read and write permissions with the file. I have included the revised script, perhaps you could help me sort this out. Thanks, James.

set textPath to {“Public:Customer Artwork:CUST LIBRARY:ENVTXT2:”}
set fontList to {“A- BrushScript”, “B- FranklinGothic”, “C- Souvenir”, “D- UniversityRoman”, “E- Helvetica”, “F- KauflinKoffee”, “G- Optimum”, “H- CopperPlate”}
set stockList to {“CopperPlate”, “Helvetica”, “NewBaskerville”}

tell application “QuarkXPress”
activate
if (exists document 1) is true then
try
set workpath to (“” & (path to current user folder)) & “Desktop:” as text
tell application “QuarkXPress”
set filepath to workpath & “file.qxp”

			save document 1 in filepath version 80
			close document 1 saving no
			delay 2
			
			tell application "QuarkXPress" to open ((path to desktop) & "file.qxp")
		end tell
	end try
end if


delay 5
tell application "QuarkXPress"
	
	display dialog "Enter Customer Number" with default answer
	set custNumber to text returned of result
	
	tell document 1
		set targetBox to object reference of (text box 1 whose selected is true)
		set targetBox2 to object reference of (text box 2 whose selected is true)
	end tell
	
	
end tell




if (exists document 1) then
	set targetPage to targetBox
	
	set custBug to (every text box whose name is "ENVBUG") of page 1 of document 1
	set targetBug to (every text box whose name is "ADDR") of page 1 of document 1
	
	
	
end if

end tell

–select styles
tell application “QuarkXPress”
beep
display dialog " Stationery or Stock Styles?" buttons {“Stationery”, “Stock”}
if button returned of the result is “Stationery” then
set stationeryStyles to item 1 of (choose from list fontList with prompt “Stationery” without multiple selections allowed)
else
set stockChoice to item 1 of (choose from list stockList with prompt "Stock " without multiple selections allowed)

end if

end tell

–format page
tell application “QuarkXPress”
set importStyles to true
set custBug to “EN” & custNumber
set textFormat to textPath & item 1 as text
set story1 of targetBox2 to {textPath} & item 1 as text
set story1 of targetBox to {custBug} as text
end tell