InDesign scripting question

I am writing an applescript for InDesign and can’t seem to write the needed script to set an active layer. I have tried telling the document, the spread, the page, etc., and each gives the error that they can’t set the active layer to the one I’m saying, yet I definitely have it in the document. Could someone give me the script for this or tell me what I’m missing.

rikard,

tell application “Adobe InDesign CS2”
tell document 1
set active layer of layout window 1 to layer “Layer 1”
end tell
end tell

here you go I’m curious though why do you want to make a layer the active layer ?

mm

that worked–tks. i am doing a script for a publication that is being done in 15 languages. i have a master indesign file which has layers for each of the languages as the art doesn’t change–just the text. each publication uses a different barcode and thus my script takes the barcodes and puts them on the applicable language layer.

there’s one other thing i’m running into. my barcodes are named by language, such as: “barcode DAN.tiff” This is Danish. In my InDesign file, the name of the Danish layer is “Danish”. Thus I wrote up properties that define all abbreviations, such as {dan:“Danish”}. I am trying to then use a shortened version of the document name (i.e., just “DAN”) to identify the layer. I could obviously have an if statement for each language, such as "if file_name equals “DAN” then set active layer to layer “Danish”, but that ends up with 15 different if statements as I am doing 15 different languages. Maybe you know of a better way of working this into the script as there will be other things that I populate these language layers with as well.

rr

Rikard,

I still don’t see the reason to make the layer an active layer. You can put an object on a layer without making it active.


tell application "Adobe InDesign CS2"
    tell document 1
        place "barcode DAN.tiff" on first layer whose name contains "DAN"
    end tell
end tell

I haven’t test this and you have to give the full file path to the image

as far as you second question, you could do somthing like this


tell application "Adobe InDesign CS2"
    tell document 1
        set active layer of layout window 1 to first layer whose name contains "DAN"
    end tell
end tell

I haven’t tested this either but I think you get the idea

ok, i see where you’re going with this and that’s probably a better logic. one last point here–I am pasting from the clipboard as opposed to placing, as i want the barcode in the file as a path, rather than just an external link. the way i do this is first open it in illustrator, copy the paths, then go into indesign, activate the layer i want it on, and then paste. unfortunately the paste command, as far as i know, doesn’t have a feature to say which layer–it just pastes. any suggestions on that?

make a new text frame on the layer that you want the text on then set then contents of the text frame to the contents of the clip board

mm

will this work if the clipboard isn’t text? The clipboard is the barcode, copied as paths from illustrator…

no to do what you are doing you will need to either make the layer the active layer or move the objects to the intended layer after pasting or yo could place the file as an eps and then embed the the image

mm