I have hopefully an easy question. I need help in grasping how to write a script to import .xtg files into Quark 6. I have a folder with several .xtg files and need to be able to import a few into a Quark document. I also would like to include stylesheets and convert quotes. I figured since you can do this manually, it should be scriptable as well.
I use this script. It’s a combination of several things.
In short: You select a location and give a new filename, then you select a folder with the .xtg-files. All thes files will be combined to one file, which will be imported in a new quarkdocument.
property pageWidth : "210 mm"
property pageHeight : "297 mm"
global theTextfile
--Choose new filename and location
set theTextfile to (choose file name with prompt "Choose filename and location for the new text file.")
set folder_ to (choose folder with prompt "Choose folder with text files.")
tell application "Finder" to set files_ to files of folder_ as alias list
-- Combine all text files to one new file.
try
set file_ref to open for access theTextfile with write permission
repeat with file_ in files_
set text_ to read file_
write (text_ & (ASCII character 12)) to file_ref starting at eof
end repeat
try
close access file_ref
end try
on error e
display dialog e
try
close access file_ref
end try
end try
--Make new quark document and put text.
tell application "QuarkXPress Passport"
activate
set import styles to true
do script {newDoc}
do script {putText}
tell document 1
set auto page insertion location to no auto page insertion
set view scale to fit page in window
show page 1
end tell
end tell
--Make new quark document.
script newDoc
tell application "QuarkXPress Passport"
tell default document 1
set properties to {automatic text box:true, facing pages:false, horizontal measure:millimeters, vertical measure:millimeters, keep master page items:false, top margin:"10mm", left margin:"10mm", bottom margin:"10mm", right margin:"10mm", column count:"1", gutter width:"4mm"}
set page width to pageWidth
set page height to pageHeight
end tell
make new document at beginning
end tell
end script
--Import the new text file.
script putText
tell application "QuarkXPress Passport"
tell document 1
set auto page insertion location to end of story
try
tell text box 1
set story 1 to alias theTextfile
end tell
end try
end tell
end tell
end script