Copy link to clipboard
Copied
I am trying to script the following with AppleScript:
1. User chooses reference and target files
2. open the reference file
3. Select and copy the objects on a specific layer to the clipboard
4. Paste clipboard contents into specific layer in target file
The InDesign CS3 dictionary has a copy command, but I encounter an error every which way I try to use it
copy v : Copies the selection in the active document window to the clipboard.
My script so far:
-- prompt user for reference and target files
set the reference_file to choose file with prompt "Select the InDesign reference file:" without invisibles
--set the target_file to choose file with prompt "Select the target file:"
tell application "Adobe InDesign CS3"
activate
set myLayer to "Layer 1"
open reference_file
tell active document
set reference_layer to object reference of (layer myLayer)
select every page item of reference_layer
copy selection
--close reference_file saving no
end tell
end tell
ERROR MESSAGE:
"Adobe InDesign CS3 got an error: selection of active document doesn’t understand the copy message."
Any one know how to use the copy verb correctly?
Hi:
Try using
copy
by itself, without a following parameter. In my scripts, I tell the App to do this, not the document or page.
hth,
egr
Copy link to clipboard
Copied
It might be as simple as
set selection to every page item of reference_layer
Copy link to clipboard
Copied
Hi:
Try using
copy
by itself, without a following parameter. In my scripts, I tell the App to do this, not the document or page.
hth,
egr
Copy link to clipboard
Copied
thank you both for your assistance. separating the copy into it's own tell block did the trick.
Copy link to clipboard
Copied
There's no need to copy -- use the duplicate command instead. It'll be quicker, and doesn't overwrite the clipboard's contents:
tell application "Adobe InDesign CS3"
set active layer of document 2 to "Layer 1" -- the target document
duplicate (every page item of document 1 where name of its item layer is "Layer 1") to page 1 of document 2
end tell
Copy link to clipboard
Copied
Thanks for the suggestion.
In testing I run into the following two errors:
1. The set active layer fails with the following message:
"Adobe InDesign CS3 got an error: Can’t set active layer of alias \"MAC4025:Users:gfloro:Desktop:copy_ref2target:Document2.indd\" to \"Layer 1\"."
2. the duplicate line erros with the following message:
"Adobe InDesign CS3 got an error: every page item of alias \"MAC4025:Users:gfloro:Desktop:copy_ref2target:Document1.indd\" whose name of «class pilr» = \"Layer 1\" doesn’t understand the duplicate message."
I'll continue testing away, but if you have any other suggestions, I'll be glad to try them out.
Thanks,
Gregory
Copy link to clipboard
Copied
I just tried it and it does work. Do both of your document have only a single page? If not the you will have to address which page of Document 1 you wish to duplicate. Have both documents open and Document 1 foremost, then run the script.
Copy link to clipboard
Copied
Larry,
I just tried again, removed all my additions to the suggested script, and it to work. Though when the items were duplicated from one document to the other, the stacking order changed.
Copy link to clipboard
Copied
Here's what I tried and it worked for me
tell application "Adobe InDesign CS3"
set active layer of document 2 to "Layer 1" -- the target document
(duplicate (every page item of document 1 where name of its item layer is "Layer 1") to page 1 of document 2) send to back
end tell
Copy link to clipboard
Copied
>the stacking order changed
Yes -- the page items actually get duplicated one at a time. One solution is to temporarily group them, then ungroup after the duplicate. Or duplicate them one at a time, doing your own ordering.
Copy link to clipboard
Copied
> In testing I run into the following two errors:
They suggest you were using references to files, not open InDesign documents.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more