Indesign - How to convert a block of text into a button?


I’m trying to convert a block of text into a button. As you would do with Window > Interactive > Buttons and Forms > Convert to Button
I’ve searched the web and I’ve only found solutions that create new buttons, not to convert a frame to a button

Thanks for your help

Hum… Block of text = text frame of course…

The easiest way is:

tell application id "InDn"
	invoke (menu action id 83458)
end tell

Funny… I used a tell application “System Events” to achieve this.
Isn’t it possible to do this more cleanly?

Invoke menu action is totally reliable, unlike SE.

There’s no command like ‘convert to button’ in InDesign.
You can find a convert shape but it’s useless here.

If you want to, you can toy with something like the following:

tell application id "InDn"
	-- get the original frame
	set theFrame to item 1 of selection
	-- make a button
	set theButton to make new button at beginning of parent of selection with properties (properties of theFrame)
	-- convert its 'content box' to a text frame
	set (content type of (rectangle 1 of group 1 of theButton)) to text type
	set theBox to (text frame 1 of group 1 of theButton)	
end tell

This snippet will create a button above your text frame, leaving the latter in place.
After that you’ll need to re-build any property of the text frame inside the button to retrieve it aspect.
This because there’s an inconsistance in InDesign scripting : set properties of theBox to properties of theFrame will have no effect.

Here are some examples:

	set fill color of theButton to fill color of theFrame
	set contents of theBox to contents of contents of theFrame
	set top left corner option of theBox to top left corner option of theFrame
	set top left corner radius of theBox to top left corner radius of theFrame
	tell text frame preferences of theBox
		set vertical justification to vertical justification of text frame preferences of theFrame
	end tell
	set justification of paragraphs of theBox to justification of paragraphs of theFrame

Have fun!

Hi Jonah,
That’s what I was afraid of. No system for converting a text frame directly into a button.
Thanks for all these explanations.

No system ???
Have you try my first suggestion?

I meant other than going through the menu…