Mobile app version of vmapp.org
Login or Join
Alves566

: Save to IDML script not working in CC2017 I'm relatively new at using scripts & the ExtendScript toolkit - and I'm working in an office environment where I'm using Adobe CC2017 and coworkers

@Alves566

Posted in: #AdobeIndesign #CreativeCloud #IndesignScripting #Save #Script

I'm relatively new at using scripts & the ExtendScript toolkit - and I'm working in an office environment where I'm using Adobe CC2017 and coworkers are using CS5.

In order for my InDesign files to be usable by all in my department, my understanding is that I need to save my files as IDML files. Ideally, I'd love a script or option that could always enable me to either save files as .idml (as a default) or as both .indd and .idml.

The script that I was using was the one provided in the answer below. (Note that this wasn't an ideal solution, since it only triggered when I chose "Save As" and not "Save". An ideal solution would be an option to save as .idml by default.)

Script to always save IDML with INDD
#targetengine "session"
// we need a targetegine to make this work
var doc = app.activeDocument; // get the current doc

// now to the event listener
app.addEventListener('afterSave', function(theEvent) {
$.writeln('saving'); // just to see whats going on
if (!doc.saved) {
// catch those possible mistakes
alert('doc was never saved');
exit();
}
var aName = doc.name; // get the name
var newName = aName.replace("indd", "idml"); // replace the indd to idml
// crate a new File Object next to the indd
var theFile = File(File(doc.filePath).fsName + "/" + newName);
// export
doc.exportFile(ExportFormat.INDESIGN_MARKUP, theFile, false);
});


However, after my CC2017 update, I get the following error message when trying to run the script:

Cannot execute script in target engine 'session'!
(#57) Engine 'session' does not exists!

Has anyone else experienced this same issue and if so, do you have any advice how to restore the script (or suggest a better solution for saving to .idml by default) ?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Alves566

2 Comments

Sorted by latest first Latest Oldest Best

 

@Kimberly620

Recently I found a fix for my problem. Ashraf Ali has a blog post that addresses my issue here: ashrafali.net/thoughts/saving-idml-files-automatically-on-close-of-indesign-document
// This InDesign Startup Script saves an IDML copy of the doc alongside the INDD
// Save it in your Startup Scripts folder. (See forums.adobe.com/thread/588551) // Thanks to fabiantheblind graphicdesign.stackexchange.com/a/71736/67488 for the original script
// Modified by Ashraf (ashrafali.net) for comment & code clarity as well as functionality on close
#targetengine "session"
// Activate a Target Engine to make this work. See stackoverflow.com/questions/14061690/what-is-targetengine
app.addEventListener('afterOpen', function(myEvent) {
// Only run once a document is opened. See forums.adobe.com/message/5410190 if(app.layoutWindows.length == 0) return; // This is here to avoid a run on first start when there are no windows

var doc = app.activeDocument; // Get the current doc

// Switch to the event listener
// If you want it to work on every save, change variable to afterSave
app.addEventListener('afterClose', function(theEvent) {
$.writeln('saving'); // just to see whats going on
if (!doc.saved) {
// catch those possible mistakes
alert('Doc was never saved');
exit();
}
var aName = doc.name; // get the name
var newName = aName.replace("indd", "idml"); // replace the INDD to IDML
// Create a new File Object next to the INDD
var theFile = File(File(doc.filePath).fsName + "/" + newName);
// export
doc.exportFile(ExportFormat.INDESIGN_MARKUP, theFile, false);
});
});


I'm now back to my desired workflow of automatically saving to IDML when I save (or close) an INDD file.

10% popularity Vote Up Vote Down


 

@Smith574

There is no reason to use a script in newer editions of InDesign as the IDML feature is under Export. Just go to File -> Export choose Format: InDesign Markup (IDML). If you are worried about the continuous steps learn to use shortcuts which is cmd+E then choose Format: InDesign Markup (IDML).

If you want to really use the script you're going to need to reference the documentation to figure out where the difference is as Adobe is known for changing the name and functions of objects. Some good sources are:


jongware
InDesign developer documentation


To clarify, Adobe may have modified their objects as they tend to do when pushing a new version and while this is built in you could work on your scripting and build a validator to check to see if you did save as IDML. If you're worried about if the export was done corerctly then after export re-open the file review or save as an INDD to test.



EDIT:

Also note to save a document as IDML you can also use the save as function located from File -> Save As or by pressing Ctrl+Alt+Shift+S (Windows) or Command+Option+Shift+S (Mac OS)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme