Skip to main content
Participant
June 26, 2023
Answered

Open Find/Change panel by script in InDesign!

  • June 26, 2023
  • 5 replies
  • 3563 views

Hello,

In InDesign, I want to use the following code to open the Find/Change panel:
app.panels.itemByName("$ID/Find/Change...").visible = true;
Unfortunately, I have not been successful. On the other hand, the code below:
var myMenuAction = app.menuActions.item("Find/Change...");
myMenuAction.invoke();
cannot specify visible = true. Any help is highly appreciated.


Kind regards, Aprking

This topic has been closed for replies.
Correct answer FRIdNGE

var fc = app.menuActions.itemByName("Find/Change...");
if(fc.enabled){
fc.invoke();
}

Error Number: 45

Error String: Object is invalid

Line: 2

Source: if (fc.enabled) {


Rob,

 

First, "app.menuActions.itemByName("Find/Change...")" doesn't work on a French ID version, you will need: app.menuActions.itemByName("Rechercher/Remplacer...").

Then, your code is irrelevant if the op plays on an open doc! That is, I suppose, a minimal condition (no sense trying to run a find/replace without a target document).

 

(^/)

5 replies

Aprking
Inspiring
June 27, 2023

 

Today, I performed a detailed test of the code snippet:

 

Copy Code
var fc = app.menuActions.itemByID(18694);
if(fc.enabled){  
    fc.invoke();  
}   

Unfortunately, the "Find/Change" panel started switching back and forth between hidden and visible again. I'm frustrated...

FRIdNGE
June 27, 2023

No comment but I'm a little lost reading this thread and all these "correct answers" that don't seem finally to be so correct!

 

(^/)

Aprking
Inspiring
June 27, 2023

I'm sorry, you're right! The answer we obtained yesterday was not correct.

Robert at ID-Tasker
Legend
June 26, 2023

What exactly are you trying to achieve? 

 

Aprking
Inspiring
June 27, 2023

app.panels.itemByName("$ID/Character").visible = true;

Just like this code, it opens the panel when executed, instead of toggling between hidden and visible.

rob day
Community Expert
Community Expert
June 26, 2023

Hi @Sherylz , Find/Change... is not a panel, so you have to specify a menuAction to open it, and it won’t open unless the menu item is enabled—there’s no visible property, but there is an enabled property. So (Code Edited):

 

 

var fc = app.menuActions.itemByID("18694");
if(fc.enabled){  
    fc.invoke();  
}

 

 

What are you going to do in the dialog when it is open? Text and Grep searches are fully scriptable without opening the dialog.

Aprking
Inspiring
June 26, 2023

Error Number: 45

Error String: Object is invalid

Line: 2

Source: if (fc.enabled) {

rob day
Community Expert
Community Expert
June 26, 2023

Do you have a document open?

Aprking
Inspiring
June 26, 2023

I apologize for any confusion. It is unclear whether the error is caused by the "/" symbol or the "..." symbol in Find/Change..., or if Find/Change... simply does not support parameters like "visible = true".

Community Expert
June 26, 2023

Does this work

app.menuActions.item("$ID/Find/Change...").invoke();

 

 

Aprking
Inspiring
June 26, 2023
app.menuActions.item("$ID/Find/Change...").invoke();

No,Cannot specify visible = true. Not sure about the state of the panel.

FRIdNGE
June 26, 2023
app.menuActions.itemByID(18694).invoke();
 
(^/)  The Jedi