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

Converting a pageItem to Interactive Element using a script

Community Beginner ,
Nov 04, 2020 Nov 04, 2020

Copy link to clipboard

Copied

Hi,

 

Can you pls tell me how to convert a pageItem into an interactive element (listBox, comboBox, textBox, SignatureBox, etc) using a script? I'm looking for a way to do that NOT by invoking a menu. Also notice that for interactive elements with states there is a command to add pageItems into each state. For the stateless interactive elements how can we do the same?

 

e.g. In a inDesign document we have a rectangle (with a pisture in it) and a polygon grouped together. How can we convert that group to a listBox (NOT by invoking a menu). Converting them we want these pageItems to keep the same ids (group, rectangle, polygon).

 

Regards,

Jim

TOPICS
How to , Scripting

Views

237

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

correct answers 1 Correct answer

Community Expert , Nov 04, 2020 Nov 04, 2020

Hi Jim,

I fear, you have to use the appropriate menu actions to do what you want.

Found no method in the scripting DOM for this use case.

 

Example that is working:

 

 

// First select the first text frame on spread 1 of your active document:
var textFrameToConvert = app.documents[0].spreads[0].textFrames[0];
app.select( textFrameToConvert );

// Then check, if the menu action is available:
// Menu command "Convert To Text Field":
var convertToTextField = app.menuActions.itemByName("$ID/$$$/Comm
...

Votes

Translate

Translate
Community Expert ,
Nov 04, 2020 Nov 04, 2020

Copy link to clipboard

Copied

Hi Jim,

do you want to do all of this with InDesign Server?

If not, why do you want to avoid menu actions that are invoked by scripting?

 

Regards,
Uwe Laubender

( ACP )

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 Beginner ,
Nov 04, 2020 Nov 04, 2020

Copy link to clipboard

Copied

Hi Laubender, Thanks for the reply. Code is faster, code is cleaner and probable will return the new object.

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 ,
Nov 04, 2020 Nov 04, 2020

Copy link to clipboard

Copied

LATEST

Hi Jim,

I fear, you have to use the appropriate menu actions to do what you want.

Found no method in the scripting DOM for this use case.

 

Example that is working:

 

 

// First select the first text frame on spread 1 of your active document:
var textFrameToConvert = app.documents[0].spreads[0].textFrames[0];
app.select( textFrameToConvert );

// Then check, if the menu action is available:
// Menu command "Convert To Text Field":
var convertToTextField = app.menuActions.itemByName("$ID/$$$/Command/TextField");

// If available:
if(convertToTextField.enabled)
{
	convertToTextField.invoke();
};

 

 

That means:

[1] You need a selection of the page item you want to convert.

[2] Because I am using a selection and a menu action the code will not run on InDesign Server.

 

Maybe someone chimes in who has a better solution…

 

EDIT: Changed my code a bit.

 

Regards,
Uwe Laubender

( ACP )

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