Copy link to clipboard
Copied
Hi Experts,
I have a very specific question.
I am using applescript to automate InDesign for a while, but now I got stucked.
So, basically my problem is that in the InDesign user interface I can easily insert a group/graphic/text frame/etc into an other text frame with no problem. See picture below:
From Applescript I can read out the content of the text frame, which says it is still "test" only, but anyway, I can find the inserted object in the page items of the text frame. So If there is a text frame that contains such an object or page item, I can read out.
BUT, and here is the question: how can I insert the object into the text frame using Applescript? It's not enough if I just anchor the objects together, because in the user interface of InDesign I insert the object directly into the content.
Does that make sence? Can someone help me out?
Thank you very much in advance.
Ravast
Copy link to clipboard
Copied
I don't know AS but in order to place object in the text you need to select InsertionPoint - or get a reference to it - and then do Paste.
Copy link to clipboard
Copied
Hi @Raavst , You would use paste into if you wanted to paste a group into a text frame replacing the text. If you want to anchor the group you would select an insertion point and paste (not paste into).
So paste into:
tell application id "com.adobe.indesign"
--the document’s first text frame
set tf to item 1 of every text frame of active document
--a selected group
set sel to item 1 of selection
--copy and paste into the text frame
copy
select tf
paste into
end tell
Before and after:
Or to anchor the selected group:
tell application id "com.adobe.indesign"
set tf to item 1 of every text frame of active document
set sel to item 1 of selection
copy
--paste at the text frame’s first insertion point
select insertion point 1 of tf
paste
end tell
After:
Copy link to clipboard
Copied
Hi rob day
Wow, you are my hero. 🙂
How the hell could you find it out? I mean, what is the logic behind taking item 1 of selection? What is exactly item 1?
I really would like to understand this logic a bit deeper.
Wow again 🙂
Thank you
Copy link to clipboard
Copied
Copy link to clipboard
Copied
what is the logic behind taking item 1 of selection
Getting the selection returns a list (or an array) not a single object. The list might have a single object, but you still have to ask for item 1 in order to get it. So with a single object selected:
tell application id "com.adobe.indesign"
set sel to selection
-- returns a list of 1 item: {rectangle id 256 of spread id 241 of document id 24 of application "Adobe InDesign 2021"}
set sel to item 1 of selection
--returns an object (no curly brackets): rectangle id 256 of spread id 241 of document id 24 of application "Adobe InDesign 2021"
end tell