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

Open Find/Change panel by script in InDesign!

New Here ,
Jun 26, 2023 Jun 26, 2023

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

1.5K

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 8 Correct answers

Community Expert , Jun 26, 2023 Jun 26, 2023

Does this work

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

 

 

Votes

Translate

Translate
Guide , Jun 26, 2023 Jun 26, 2023
app.menuActions.itemByID(18694).invoke();
 
(^/)  The Jedi

Votes

Translate

Translate
Community Expert , Jun 26, 2023 Jun 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.

Votes

Translate

Translate
Community Expert , Jun 26, 2023 Jun 26, 2023

Sorry, there was a type-o in my post should be itemByID as @FRIdNGE is showing but with the enabled test:

 

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

 

 

But this should also work:

 

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

 

 

Votes

Translate

Translate
Guide , Jun 26, 2023 Jun 26, 2023

… Maybe I don't understand something but theese two codes give the same result if the Find/Replace window is or not visible.

 

Rob:

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

 

FRIdNGE:

app.menuActions.itemByID(18694).invoke();

 

(^/)

Votes

Translate

Translate
Community Expert , Jun 26, 2023 Jun 26, 2023

but theese two codes give the same result

 

Hi @FRIdNGE , You are right they do the same. I was just trying to show there is an .enabled property, but no .visible property. I could add an alert in case the menu item happens to be grayed out:

 

var fc = app.menuActions.itemByName("Find/Change...");
if(fc.enabled){  
    fc.invoke();  
} else {
    alert("Find/Change is not Available")
}

 

Screen Shot 22.png

Votes

Translate

Translate
Community Expert , Jun 26, 2023 Jun 26, 2023

Is there a method like item("$ID/Find/Change...")

 

That should also work, see @Eugene Tyson ’s post. But as with the other options nothing would happen if the menu item is grayed out and disabled. So:

 

 

var fc = app.menuActions.item("$ID/Find/Change...");
if(fc.enabled){  
    fc.invoke();  
} else {
    alert("Find/Change is not Available")
}

 

 

Votes

Translate

Translate
Guide , Jun 26, 2023 Jun 26, 2023

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).

 

(^/)

Votes

Translate

Translate
Community Expert ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

FindChange... is not a panel.

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
Contributor ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

Because I often need to access the properties of text for GREP replacements, that's why I wanted to use a script to directly open the Find/Change panel. But now it's not possible anymore...

But still, I am very grateful to @rob day  and @FRIdNGE !

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 ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

What is wrong with Ctrl+F? 

 

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
Contributor ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

I'm sorry, I wanted to discuss scripting techniques rather than operational issues.

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 ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

Yes, I understand - but why? 

 

What EXACTLY are you trying to achieve? 

 

You are telling us only part of the story... If you describe the whole workflow - we can help you better... Otherwise it will be another pointless thread where solution could be given much quicker... 

 

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
Contributor ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

Currently, I am using a script to retrieve the properties of selected text and fill them into the GREP section of the Find/Change panel for search and replace. However, after obtaining the text properties, I still have to manually open the Find/Change panel by pressing Ctrl+F. It would be much more convenient if I could directly open the Find/Change panel after retrieving the text properties using the script. But now, I cannot determine the hidden and visible state of the Find/Change panel. So...

For example, if the Find/Change panel is currently hidden, and I run the script, the Find/Change panel becomes visible... Hahaha... This is a pretty funny situation.

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 ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

You still have not answered my question - WHY? 

 

What do you need to change in the Find/Change panel - that you can't do through scripting?? 

 

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
Guide ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

What properties?

 

(^/)

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
Contributor ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

textgrep.png

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 ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

And? 

 

How do you want to change them? 

 

Everything is available through scripting. 

 

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 ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

All of those properties are settable via the findGrepPreference for the search and via changeGrepPreference for the find. Here is the property listing for findGrepPreference:

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#FindGrepPreference.html

 

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