Saving text from Quark to Word

It’s a long story, but I have about 1,000 Quark 6.5 documents, each with only one text box, that need to be individually saved as MSWord documents. Here is what I have so far – or what I’ve cobbled together from other found scripts – but it doesn’t work:

set Source_Fld to choose folder with prompt “Choose Quark Source Folder” without invisibles
set Output_Fld to choose folder with prompt “Choose Text Output Folder” without invisibles
tell application “Finder”
try
set Quark_Files to (files of entire contents of Source_Fld) as alias list
on error
set Quark_Files to (files of entire contents of Source_Fld) as alias as list
end try
end tell
repeat with This_File in Quark_Files
tell application “QuarkXPress”
activate
open This_File use doc prefs yes remap fonts no
set Doc_Name to name of document 1
tell document Doc_Name
save story 1 as “WDBN” in (Output_Fld & (Doc_Name & “.doc”))
close saving no
end tell
end tell
end repeat

The problem is in the “save story 1 as” line. The script gives me this: “QuarkXPress got an error: Can’t make some data into the expected type.”

Can anyone help me with this? It seems like it should be pretty easy, but I can’t figure it out.

Maybe code as folows works for you (tried it here on my Mac with “TEXT” instead od “WDBN”):


set sourcefolder to choose folder with prompt "Choose Quark Source Folder:" without invisibles
set outputfolderpath to (choose folder with prompt "Choose Text Output Folder" without invisibles) as text

tell application "Finder"
	set quarkfiles to (files of entire contents of sourcefolder)
end tell

repeat with quarkfile in quarkfiles
	set quarkfile to quarkfile as alias
	tell application " QuarkXPressâ„¢"
		activate
		open quarkfile use doc prefs yes remap fonts no
		set quarkfilename to name of document 1
		tell document 1
			set txtbox to object reference of text box 1
		end tell
		save (story 1 of txtbox) as "WDBN" in file ((outputfolderpath & (quarkfilename & ".doc")) as text)
		close document 1 saving no
	end tell
end repeat

Thanks for the reply! Unfortunately, when I run this script I get this message:

“QuarkXPress got an error: No filter found for this file type.”

and the script line

“save (story 1 of txtbox) as “WDBN” in file ((outputfolderpath & (quarkfilename & “.doc”)) as text)”

is highlighted. Any idea why?

Model: MacPro3, Quad-Core Intel Xeon
AppleScript: 2.1.2
Browser: Firefox 3.5.6
Operating System: Mac OS X (10.4)

Hi,

You don’t seem to have the corresponding plugin installed on your system, do you? Try to use “TEXT” instead of “WDBN” and see if that works. If so, then you definitely need to install the Microsoft Word export plugin first.

Best regards,

Martin

Well, yes, I have no problem writing a batch script that exports as TEXT. I also have no problem individually saving each Quark file as a Word document. I just want to automate the process. Do I need a separate plugin to automate a process that Quark does on its own?

I guess you should get to know your available text export filters, so that you can use its name accordingly (obviously it’s not “WDBN”…) in the save command:


tell app "QuarkXPress"
activate
get text export filters
end tell

Moreover this free document mentions a Word filter suite:


export reference as filter type in alias

Bingo! That worked! Thank you so, so much! The final script is this:


set sourcefolder to choose folder with prompt "Choose Quark Source Folder:" without invisibles
set outputfolderpath to (choose folder with prompt "Choose Text Output Folder" without invisibles) as text

tell application "Finder"
	set quarkfiles to (files of entire contents of sourcefolder)
end tell

repeat with quarkfile in quarkfiles
	set quarkfile to quarkfile as alias
	tell application "QuarkXPress"
		activate
		open quarkfile use doc prefs yes remap fonts no
		set quarkfilename to name of document 1
		tell document 1
			set txtbox to object reference of text box 1
		end tell
		save (story 1 of txtbox) as "Microsoft Word 97/98/2000" in file ((outputfolderpath & (quarkfilename & ".doc")) as text)
		close document 1 saving no
	end tell
end repeat