Highlighted

Applescript get formatted text from frame

Community Beginner ,
Apr 20, 2020

Copy link to clipboard

Copied

Hi.

I'm working in a script that takes the text of all text frames and put them in a Numbers file. It's working fine, but just plain text. Is there a way to "set myText to (every paragraph)" and keep formatting? 

Indesign comes with that script that exports all stories to RTF, but it seems that RTF only works while exporting. 

Any idea?

 

Thank you,

Luiz

Adobe Community Professional
Correct answer by rob day | Adobe Community Professional

You should be able to use the Clipboard, something like this:

 

 

 

tell application "Adobe InDesign 2020"
	
	set copy PDF to clipboard of clipboard preferences to true
	
	--a selected text frame
	set sel to selection
	set t to object reference of text of item 1 of sel
	
	-- select and copy the text
	select t
	copy
	
	
	tell application "Numbers"
		activate
		
		--set the insertion point in the target cell
		set the value of cell "A2" of table 1 of sheet 1 of the front document to ""
		
		--paste the clipboard contents
		tell application "System Events" to keystroke "v" using {command down}
	end tell
end tell

 

 

Screen Shot 8.png

 

TOPICS
How to, Scripting

Views

92

Likes

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

Applescript get formatted text from frame

Community Beginner ,
Apr 20, 2020

Copy link to clipboard

Copied

Hi.

I'm working in a script that takes the text of all text frames and put them in a Numbers file. It's working fine, but just plain text. Is there a way to "set myText to (every paragraph)" and keep formatting? 

Indesign comes with that script that exports all stories to RTF, but it seems that RTF only works while exporting. 

Any idea?

 

Thank you,

Luiz

Adobe Community Professional
Correct answer by rob day | Adobe Community Professional

You should be able to use the Clipboard, something like this:

 

 

 

tell application "Adobe InDesign 2020"
	
	set copy PDF to clipboard of clipboard preferences to true
	
	--a selected text frame
	set sel to selection
	set t to object reference of text of item 1 of sel
	
	-- select and copy the text
	select t
	copy
	
	
	tell application "Numbers"
		activate
		
		--set the insertion point in the target cell
		set the value of cell "A2" of table 1 of sheet 1 of the front document to ""
		
		--paste the clipboard contents
		tell application "System Events" to keystroke "v" using {command down}
	end tell
end tell

 

 

Screen Shot 8.png

 

TOPICS
How to, Scripting

Views

93

Likes

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
Apr 20, 2020 0
Adobe Community Professional ,
Apr 20, 2020

Copy link to clipboard

Copied

You should be able to use the Clipboard, something like this:

 

 

 

tell application "Adobe InDesign 2020"
	
	set copy PDF to clipboard of clipboard preferences to true
	
	--a selected text frame
	set sel to selection
	set t to object reference of text of item 1 of sel
	
	-- select and copy the text
	select t
	copy
	
	
	tell application "Numbers"
		activate
		
		--set the insertion point in the target cell
		set the value of cell "A2" of table 1 of sheet 1 of the front document to ""
		
		--paste the clipboard contents
		tell application "System Events" to keystroke "v" using {command down}
	end tell
end tell

 

 

Screen Shot 8.png

 

Likes

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
Reply
Loading...
Apr 20, 2020 0
Community Beginner ,
Apr 20, 2020

Copy link to clipboard

Copied

Perfect! Thank you. 

Likes

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
Reply
Loading...
Apr 20, 2020 0