Quark Copy and Paste text doc to doc into single text box

Setting up a script that basically takes the text from multiple text files and copies them each into a single text box in another document. The files in question always have the text box in the same position on the page so identifying the text boxes is easy. I have had difficulty copying and pasting in when scripting Quark before so I figured I would check to see if anyone has a better way than how I am going. The main concern is that I want to keep all of the text formatting of the text I am copying when I paste it into the new doc. I tried setting a variable to the text but that stripped the text of its formatting. Here is the main Quark part of what I have. This works although I am not sure yet how I would copy the next part and append it to the text box.

Quark 6.5 OS 10.3.9


tell application "QuarkXPress"
	activate
       --Open template, find main text box, name it so it can be referenced, delete what is in there, save as
	open file PathToTemplate use doc prefs yes remap fonts ask do auto picture import yes
	tell front document
		set tool mode to drag mode
		tell page 1
			repeat with Countr from 1 to count of text boxes
				tell text box Countr
					copy (right of bounds of it as real) to YCoord
					if YCoord is greater than 0.25 then
						set name of it to ("MainTextBox")
						set story 1 of it to ""
						exit repeat
					end if
				end tell
			end repeat
		end tell
	end tell
	save front document in file (PathToDesktop & MainFileName & ".qxp") without template and include preview
	close front document
       --Open file with text to copy, identify text box, name it, select text in text box and copy it with command-C
	open file (PathToPart1 & PartOneFile & ".qxp") use doc prefs yes remap fonts ask do auto picture import yes
	delay 3
	tell front document
		set tool mode to contents mode
		tell page 1
			repeat with Countr from 1 to count of text boxes
				tell text box Countr
					copy (top of bounds of it as real) to YCoord
					if YCoord is greater than 1 and YCoord is less than 2 then
						set name of it to ("ThisBox")
						exit repeat
					end if
				end tell
			end repeat
			delay 0.5
			select paragraph 1 of story 1 of text box "ThisBox"
			tell application "System Events"
				keystroke "c" using {command down}
			end tell
		end tell
	end tell
	close front document saving no
       --Open main doc again, paste into text box followed by a return to set up next paragraph
	open file (PathToDesktop & CCMNumber & FileVersion & ".qxp") use doc prefs yes remap fonts ask do auto picture import yes
	tell front document
		set tool mode to contents mode
		tell page 1
			select story 1 of text box "MainTextBox"
			tell application "System Events"
				keystroke "v" using {command down}
				keystroke return
			end tell
		end tell
	end tell
end tell


Model: Mac G5
Operating System: Mac OS X (10.3.9)

Just thought I would bring this to the top of the posting list. Any new Quark scripters out there with some ideas??

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

Matt,

I haven’t scripted Quark in a while but you should be able to just use the copy and paste commands within Quark, no system events needed. Make sure that you have selected the proper tool mode and that your text is selected whey you are copying. However, with the code that you have I think that you need to tell system events the process that you are targeting (Quark). I don’t have a copy of Quark here to test this on or I would try to get it working for you, but this is what I would try:

tell application "QuarkXPress"
   activate
--Open template, find main text box, name it so it can be referenced, delete what is in there, save as
   open file PathToTemplate use doc prefs yes remap fonts ask do auto picture import yes
   tell front document
       set tool mode to drag mode
       tell page 1
           repeat with Countr from 1 to count of text boxes
               tell text box Countr
                   copy (right of bounds of it as real) to YCoord
                   if YCoord is greater than 0.25 then
                       set name of it to ("MainTextBox")
                       set story 1 of it to ""
                       exit repeat
                   end if
               end tell
           end repeat
       end tell
   end tell
   save front document in file (PathToDesktop & MainFileName & ".qxp") without template and include preview
   close front document
--Open file with text to copy, identify text box, name it, select text in text box and copy it with command-C
   open file (PathToPart1 & PartOneFile & ".qxp") use doc prefs yes remap fonts ask do auto picture import yes
   delay 3
   tell front document
       set tool mode to contents mode
       tell page 1
           repeat with Countr from 1 to count of text boxes
               tell text box Countr
                   copy (top of bounds of it as real) to YCoord
                   if YCoord is greater than 1 and YCoord is less than 2 then
                       set name of it to ("ThisBox")
                       exit repeat
                   end if
               end tell
           end repeat
           delay 0.5
           select paragraph 1 of story 1 of text box "ThisBox"
           copy
       end tell
   end tell
   close front document saving no
--Open main doc again, paste into text box followed by a return to set up next paragraph
   open file (PathToDesktop & CCMNumber & FileVersion & ".qxp") use doc prefs yes remap fonts ask do auto picture import yes
   tell front document
       set tool mode to contents mode
       tell page 1
           select story 1 of text box "MainTextBox"
          paste
       end tell
   end tell
end tell