Saving QuarkExpress text boxes as plain text

I need to save all text boxes in a large QuarkXpress 6.0 file as plain text file.
each text file named file1, file2 etc…

I was doing this manually but it is taking forever.!!
Can this be done??

This should save all the stories as text files in a folder on your desktop “�name of document 1� Stories”:

tell application "QuarkXPress" to set the_name to name of document 1
try
    tell application "Finder" to set the_parent_folder to (make new folder at desktop with properties {name:the_name & " Stories"}) as string
on error
    set the_parent_folder to ((path to desktop as string) & the_name & " Stories:") as string
end try

tell application "QuarkXPress"
    tell document 1
        try
            set all_stories to object reference of stories
        on error
            return
        end try
        repeat with i from 1 to (count of all_stories)
            set the_file to the_parent_folder & the_name & " story " & (i as string) & ".txt"
            my write_to_file(the_file, (text of item i of all_stories))
        end repeat
    end tell
end tell
beep

on write_to_file(the_file, the_story)
    set the_file to the_file as file specification
    try
        open for access the_file with write permission
        write the_story to the_file
        close access the_file
    on error the_error
        try
            close access the_file
        end try
    end try
end write_to_file

Jon

Thanks,
but i get this error:
QuarkXPress got an error: Can’t get every text of text from character 1 to character 1180 of document “01-Soler_Fluxes_W”.

It creates the folder but not he text files.

I don’t have QXP 6.1 to test but on 5.x, 4.x, & 3.x, this works. Maybe a slight change will work:

tell application "QuarkXPress" to set the_name to name of document 1
try
    tell application "Finder" to set the_parent_folder to (make new folder at desktop with properties {name:the_name & " Stories"}) as string
on error
    set the_parent_folder to ((path to desktop as string) & the_name & " Stories:") as string
end try

tell application "QuarkXPress"
    tell document 1
        repeat with i from 1 to (count of stories)
            set the_file to the_parent_folder & the_name & " story " & (i as string) & ".txt"
            my write_to_file(the_file, ((story i) as string))
        end repeat
    end tell
end tell
beep

on write_to_file(the_file, the_story)
    set the_file to the_file as file specification
    try
        open for access the_file with write permission
        write the_story to the_file
        close access the_file
    on error the_error
        try
            close access the_file
        end try
    end try
end write_to_file

Jon

Thanks.
Different error:
Can’t make text from character 1 to character 4 of document “Project1” of application “QuarkXPress” into a string.

I have 4x at home a will give it a try.
Steve

I edited the script above so you might have taken the earlier version. Can you test the one that’s there now?

Jon

That worked great.
Thanks so much for your help!!

The script works great.
But i think it would be better if i could save the stories as xpress tags.
is this possable?