Skip to main content
josiearz
Participating Frequently
February 8, 2022
Answered

[JavaScript] Run action on object?

  • February 8, 2022
  • 2 replies
  • 380 views

I know it is possible to run actions from scripts using doScript(), but is there a way to run the action on an object using its variable name? If there is not a method for this, how do I select an object using its variable name so that when I subsequently call doScript, the action is executed on the selected object? 

 

Basically, I would like to do the following, but apparently I can't call select on a Text Frame object.

myTextFrame.select();

app.doScript("Format Text", "Text Actions")

 

Thanks!

This topic has been closed for replies.
Correct answer pixxxelschubser

Or if you have custom named text frames (not automatically named text frames).

 

//var myTextFrame = app.activeDocument.pageItems.getByName("notAnAutoName"); // works
var myTextFrame = app.activeDocument.textFrames.getByName("notAnAutoName");
myTextFrame.selected = true;

 

 

2 replies

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
February 8, 2022

Or if you have custom named text frames (not automatically named text frames).

 

//var myTextFrame = app.activeDocument.pageItems.getByName("notAnAutoName"); // works
var myTextFrame = app.activeDocument.textFrames.getByName("notAnAutoName");
myTextFrame.selected = true;

 

 

josiearz
josiearzAuthor
Participating Frequently
February 8, 2022

Thank you, this worked!

pixxxelschubser
Community Expert
Community Expert
February 8, 2022

 

Try:

var myTextFrame = app.activeDocument.textFrames[0];
myTextFrame.selected = true;