[CS4 - JS]Export stories and "object is invalid" error
Hello all,
I need a javascript script that exports all the stories of a document to .icml files.
At the moment I've come to a function like this:
function exportICML(myDoc, path) {
var stories = myDoc.stories;
for (var i = 0; i < stories.length; i++) {
alert(i);
var story = stories.item(i);
var filename = path + "/story-" + i + ".icml";
try {
story.exportFile(ExportFormat.INCOPY_MARKUP, new File(path));
} catch (err) {
alert(err.message);
}
}
}
This function fails, and in the server log I see this error:
"Object is invalid"
What am I doing wrong?
Thanks.