Skip to main content
Participant
February 5, 2010
Question

[AS] Saving a file without creating an idlk file

  • February 5, 2010
  • 1 reply
  • 772 views

Hi there,

I have an AppleScript that open an InDesign template (indt), import a XML file and then save the document to another folder than the one where the XML file and the template are living.

The problem, and I don't see how to resolve it, is that InDesign always create a lock file (idlk) with the new document and I don't seem to find a way to close the new document.

Here's the script:

Translating:

chemin_fichier_xml                           == path_to_xml_file

chemin_gabarit_indesign                   == path_to_indesign_template

chemin_nouveau_fichier_indesign      == path_to_new_indesign_file

on genere_fichier_indesign(chemin_fichier_xml, chemin_gabarit_indesign, chemin_nouveau_fichier_indesign)

tell application "Adobe InDesign CS4"

set ce_document to open chemin_gabarit_indesign without showing window

tell ce_document

tell XML import preferences

set import style to merge import

set repeat text elements to true

set import text into tables to true

set import CALS tables to true

end tell

import XML from chemin_fichier_xml

set le_nouveau_document to chemin_nouveau_fichier_indesign

tell ce_document to save to le_nouveau_document with force save

(* this will generate an error *)

-- try

-- close ce_document saving no

-- close le_nouveau_document saving yes

-- end try

end tell

end tell

end genere_fichier_indesign

TIA

Cheers

-Emmanuel

This topic has been closed for replies.

1 reply

Inspiring
February 5, 2010

If you're opening a template and want to save it as a normal document, you probably need to include the "statioery" parameter in your save. Try something like this:

tell ce_document to save to le_nouveau_document without stationery

close document 1 saving no

Participant
February 5, 2010

Hello,

Thanks for replying.

I still get an idlk file and an error.

--> Adobe InDesign CS4 got an error: Can’t get document 1 of document "Sans titre-3"

I tried other variation:

close file le_nouveau_document saving no

--> Can’t get file "HD:Users:stereo:Applications:Automatisation Téléhoraires:Dossiers:InDesign - À valider:StThomasTimesJournal_20100131_1009_1_Quot.indd" of document "Sans titre-2".

close documents saving no

-->  Can’t get every document of document "Sans titre-3"

I'm on Snow Leopard 10.6.2 and use ID CS4 v6

Cheers

-Emmanuel

Inspiring
February 5, 2010

You need to move outside the "tell ce_document" block. In fact, if you only have one document, you're better off just referring to document 1. The problem with references like "tell ce_document" is that "ce_document" is based on the doc's name, so as soon as you save as another document, the reference no longer works.