• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Applescript and InDesign - insert group into text frame

New Here ,
Jun 25, 2024 Jun 25, 2024

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:

Screenshot 2024-06-25 at 16.37.58.png

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

 

TOPICS
Scripting

Views

195

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 25, 2024 Jun 25, 2024

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. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 25, 2024 Jun 25, 2024

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:

 

Screen Shot 6.png

 

Screen Shot 7.png

 

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:

 

Screen Shot 8.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 25, 2024 Jun 25, 2024

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 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 25, 2024 Jun 25, 2024

Copy link to clipboard

Copied

@Raavst

 

"1" is an index of an element in the collection "of something". 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 25, 2024 Jun 25, 2024

Copy link to clipboard

Copied

LATEST

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

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines