getting text into QuarkXPress text box

I am an art director, new to applescripting.
I have 70 - 150 (QuarkXPress 6) files to build from one Quark template. In the template I have 3 text changes and 2 image changes. This takes about two or three days to do.
I am trying to write an applescript that will do all of this or each of these and combine them.
Here is where I am right now.

  • Using automator, I have accessed the Microsoft Word document containing the text that I wish to insert into my Quark template and selected the paragraph I wish to extract. I can successfully copy the text I need to the clipboard or create a textedit document on my desktop (I would prefer to send it to the clipboard so that I don’t create an extra document I will have to delete later).
    -I have written my AppleScript to access the quark template and delete the template copy in the text box.
    QUESTION? How do I get my text from my word file into the text box of the quark file?
    below is the applescript I have written to access the textbox in the Quark template

tell application “Finder”
activate
select window of desktop
select window of desktop
open document file “¢Test_file.qxd” of folder “Desktop” of folder “dskipworth” of folder “Users” of startup disk
end tell
tell application “QuarkXPress”
tell document 1
tell page 1
select story 1 of text box 1
cut selection
end tell
end tell
end tell

Model: G5
AppleScript: 2.1.1
Browser: Safari 417.8
Operating System: Mac OS X (10.4)

Skip,
Try this:

tell application "QuarkXPress"
	tell document 1
		tell page 1
			select story 1 of text box 1
			paste
		end tell
	end tell
end tell

-N

This works, but it doesnt work.
Here is the resulting script which works. ( I had to change “select story 1 of text box 1/cut selection” to: “tell text box 1/delete (words 1 thru 19)” because: when I cut selection it placed the text on the clipboard and flowed it right back in on the next command.

tell application “Finder”
activate
select window of desktop
select window of desktop
open document file “test” of folder “Desktop” of folder “skipskipworth” of folder “Users” of startup disk
end tell
tell application “QuarkXPressâ„¢”
tell document 1
tell text box 1
delete (words 1 thru 19)
end tell
end tell
tell application “QuarkXPressâ„¢”
tell document 1
select story 1 of text box 1
paste
end tell
end tell
end tell

  • This works if I copy the target text onto the clipboard and then run this script, the text then replaces the text in the Quark template text box.
  • When I run my Automator Workflow ” which uses (1)“select text” to choose the target text, (2)“Filter Paragraphs” to get only the text I want, and (3)“Copy to clipboard”, it copies the desired text to the clipboard. I can open a blank textedit text box and “paste”, and the copy flows in.
  • If I run the automator workflow and then open a Quark file and “paste” into a text box, nothing happens.
  • The above script does the same thing, it comes up empty, it does not get the text placed on the clipboard from the Automator result. Quark does not seem to recognize that clipboard as being the same clipboard it accesses, or it does not recognize the text as text it can handle. I can copy fromTextEdit and paste into a quark file, so I know quark can normally handle the text, but something isn’t working once it gets to the clipboard.
  • Is there (because I can’t find it) an AppleScript command in TextEdit to copy text to the clipboard? I can make my Automator Workflow create a desktop text file and I can write a script to access that text, but I can’t get TextEdit to copy it to the clipboard. Do I need to create some kind of string or rename the text or something so I can access it from Quark"

So, my challenge remains, how to get my target text into the quark text box.

Skip,

It sounds like doing the cut and paste started out easy but is turning into more trouble than it’s worth. Just get the text in Word, store it as a variable, then put it in the Quark Doc. Here’s a start using Quark 6.5 / Word 2004 on 10.3.9 (I don’t have Tiger/Automator):

tell application "Microsoft Word"
	--activate
	
	--> choose the Word doc
	set theWordDoc to choose file
	open theWordDoc
	
	--> gets paragraph 1 (for example)
	set textToCopy to (get content of text object of paragraph 1 of active document)
end tell


tell application "QuarkXPress"
	--activate
	
	--> choose the Quark doc
	set theQuarkDoc to choose file
	open theQuarkDoc
	tell document 1
		
		--> replace/set the text in Quark
		set story 1 of text box 1 to textToCopy
	end tell
end tell

-N

In reply to Jacques,
How do I get Word to access the clipboard to get the text in order to set the clipboard selection to string? So far, I have been unsuccessful in repeated attempts.

In reply to Nedloh99,
Your suggestion works fantastically, but I have over one hundred files I will have to access, one by one. If I have to choose the file from which to get the text, then the manner it will be interpreted, and then the Quark file it will be flowed into, and repeat this process three times for each file, I am only sightly better off than cutting and pasting. Is there a way to use your script but insert the specific file names, and open the word doc using Unicode?

thanks, you guys.

And to anyone else who can help:
I can use Automator to select my Word file and extract the exact copy I need without counting anything (because there is more or less copy before the target paragraph, depending on the individual file, but the target paragraph always begins with the word “Whatever”)

I can either save the resulting text to the clipboard or to my desktop as a TextEdit file.

The missing link is getting the target paragraph in Quark so I can flow it into the selected text box. Quark doesnt recognize the text on the clipboard.

Possibilities: Can I use Microsoft Word to cut the targeted text down to the target paragraph without counting anything?

Skip,
With the code below you’ll be able to select source and desitnation folders and the finished files will be sequentially numbered. You can hardcode file paths if you choose.

There’s no error checking and I kinda threw it together, but the comments should help you understand what’s going on. You may want to do a search on these forums for “repeat handlers”. If you want to configure as a droplet, do another forum search.

--> choose the Quark doc to use
set theQuarkDoc to choose file with prompt "Select a Quark Template"

-->Where would you like the files saved?
set SavedQuarkFolder to (choose folder with prompt "Where would you like to save your files?") as string

-->get a list of the Word Docs
tell application "Finder"
	set theWordDocList to every file of folder (choose folder with prompt "Select a folder containing your Word Files")
end tell



-->Start the repeat loop with each Word Doc
repeat with i from 1 to count of theWordDocList
	
	-->set path to WordDoc
	set aWordDoc to item i of theWordDocList as alias
	
	tell application "Microsoft Word"
		
		-->opens Word Doc
		open aWordDoc
		
		--> gets paragraph 1 (for example)
		set textToCopy to (get content of text object of paragraph 1 of active document)
		
		--> closes Word Doc
		close documents saving no
		
	end tell
	
	
	tell application "QuarkXPress"
		
		-->opens Quark Doc
		open theQuarkDoc
		tell document 1
			
			--> replace/set the text in Quark
			set story 1 of text box 1 to textToCopy
			
			-->save and number Quark Doc
			save in (SavedQuarkFolder & i)
			
			-->close Quark Doc
			close
		end tell
	end tell
	
end repeat

beep 3


-N

Okay, I’ve got my Automator to get my word file, and divide it up to the three different places in the word document where I want to copy information to place into my Quark template file.
And I’ve got QuarkXPress to place the different items of text into the quark document successfully.

What I need now, is to get the name of the word file (lets call it abc.doc) where I am getting my text, and transfer that name to the Quark document created from the template (I want to call the Quark file, abc.qxd). How do I get that to happen? Everytime I use this script I need to set each Quark document name to correspond with the 70 to 150 word files I have.

And thanks so much for everyones help. When I get this finished I will post the structure of this beast for others to adopt and adapt. Automator made it easy, all I had to do is type some very specific scripts to fill in some of the voids.

Skip,

Again, I don’t know how this applies to Automator (it’s easy to add to my previously posted code) but to get the file name of the word document while it’s open:

tell application "Microsoft Word"
-->gets name up to the .doc extension
set docName to characters 1 thru -5 of (get name of active document)
end tell

and to save an open Quark Doc using that name: (refer to my last post for reference on the save part for the file path)

tell application "QuarkXPress"

tell document 1
           
           -->save and name Quark Doc
           save in (SavedQuarkFolder & docName & ".qxp")
           
-->close Quark Doc
close
end tell
end tell

Good Luck!

-N