Can I name a text box in Quark so I can locate it in Applescript

I have been conversing with you guys previously, but I want to post this as new, because I think others could find great wealth in the answer to this question, if it exists.

In my two-page quark file in which I am flowing text, I have perhaps twenty text boxes. I only address about three or four text boxes on each page with my script, so the difficulty is arranging the text boxes in Quark in the right order to get text box 1, text box 2, and so on. If someone goes into the quark file and changes the order, it really screws up the script.

Is there a way to name the text box in Quark, and get the text box in Applescript by its name, rather than by its order of arrangement to the front? I’m thinking perhaps by giving the text box a hyperlink anchor and naming the anchor, but I haven’t found in my searching very much information about getting an anchor-named hyperlinked text box in Quark. Will this work, or is there a better way, or any way at all?

Yes, you should be able to set the name property of the text box to a string that the script can call. If you have more than one text box in the document with the same name you should be able to direct the command to all of them at the same time . These example’s are may not work, I don’t have Quark at home to test it with and I’m basically going from memory here, but the basic premis is there:

tell page 1 of document 1 to set color of text box "Foo" to "Cyan"
tell document 1 to set color of every text box whose name is "Foo" to "Cyan"
Tell page 2 of document 1 to set color of every text box whose name is "Foo" to "Cyan"

My question is, how do you set the name of the text box in Quark, in order to address it in Applescript? Maybe thats a QuarkXPress type of question.

That depends on what you have to start with. I haven’t done much with scripting Quark beyond Quark 4.11 becouse I can’t bring a license home from work due to Quarks site license scheme at work, so my information might be outdated. I don’t think that Quark has a way to directly name a “box” on creation. You could buy an extension called ScriptMaster XT which will give you a way to do this, but it is a bit expensive if you ask me for what you get unless you are new to scripting Quark, in which case it will allow you to record from the script editor which could make it worth buying.

Now, if you are setting up a template, you could create a quick script to name the selected object which should be something like this:

set BoxName to display dialog "Enter box name:" default answer ""
tell application "Quark"
set name of selection to BoxName
end tell

You could duplicat that or copy and paste and the new box will have the same name as the original. Another way that might work for text boxes is to enter the name desired in the text box and have a script go though the document and set the name of the box based on the text entered in the box. You could have an image file with the name of a picture box you wanted to name and it could name to box to match the name of the file inside. Once you have the file set up, save it as a template and build new documents off of it and run your script.

If you are working with documents that already exist then you could create a script that goes through and names boxes based on certain criteria, say origin of bounds for example.

Hope that answers your question.

Thanks. I was going through a search of MacScripter and came across this posting

http://bbs.applescript.net/viewtopic.php?id=16189

where Cavedog talked about naming a text box in Quark 6.5. I only have 5.0 at home so I have to wait until Monday to check it out at work.

Well, here I am at work and I can’t find anything that will set a name to a text box in Quark 6.5.
However, I did find that I can get the textbox by the first word of text already in it. This is what I do anyway, so that when I insert the text it takes on the type characteristics of the text it replaces.


set text of (first text box whose first word is "something") to nameOfTextToInsert

Provided you have a document open and a box selected, you can do the following in Quark 6.5:

set doc1 to front document
set box1 to current box of doc1
set name of box1 to "Box 1"

Hope this helps,
Brad Bumgarner, CTA

set NewName to display dialog "Enter name for the selected box." default answer ""
tell application "QuarkXPress"
	activate
	set TheSelection to selection
	set name of TheSelection to text returned of NewName
end tell

Quick, to the point script that names the selected item based off of what you enter into the display dialog command. You should only have one item selected.

You can set the name when making new element like this as part of the box’s property list.

tell application "QuarkXPress"
	activate
	tell document 1
		make picture box at beginning with properties ¬
			{name:"Picture 1", bounds:{"10 mm", "10 mm", "60 mm", "90 mm"}, color:"Black"}
		make text box at beginning with properties ¬
			{name:"Text 1", bounds:{"60 mm", "10 mm", "80 mm", "90 mm"}, color:"Yellow"}
	end tell
end tell