Copy link to clipboard
Copied
Dear all, I'm asking for Your help.
I need to change some formula in a big book that includes cross reference. I've got repeating formula that goes like this:
Details - see page 171
Détails v. page 171
Detalles v. página 171
Dettagli v. pagina 171
The number of page is a cross-reference link which varies depending of product which it connects. My goal is to add another (polish) translation between french and spanish one. So I thought this sentence would work:
Find: (Détails v. page )(~v$)
Change: $1$2\nStronas\$2
Hovewer instead of getting right cross-reference to specific page, it changes page numer to the one, on which the sentence is located. Could You tell me, what I've done wrong?
Kind regards,
Piotr
Simplically:
… using this simple Script:
var myDoc = app.activeDocument;
// Step 1
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "Détails v\\. page ~v\\r";
myFound = myDoc.findGrep();
var F = myFound.length;
for (var f = 0; f < F; f++) myFound[f].duplicate(LocationOptions.AFTER, myFound[f]);
// Step 2
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "(Détails v\\. page) ~v\\r\\K\\1";
app.changeGrepPref
...
Copy link to clipboard
Copied
You can't use GREP variables like that, it works only for literal text. Not for cross-references, footnotes, endnotes, etc.
Copy link to clipboard
Copied
Thank You!
Copy link to clipboard
Copied
.
Copy link to clipboard
Copied
Simplically:
… using this simple Script:
var myDoc = app.activeDocument;
// Step 1
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "Détails v\\. page ~v\\r";
myFound = myDoc.findGrep();
var F = myFound.length;
for (var f = 0; f < F; f++) myFound[f].duplicate(LocationOptions.AFTER, myFound[f]);
// Step 2
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "(Détails v\\. page) ~v\\r\\K\\1";
app.changeGrepPreferences.changeTo = "Stronas";
myDoc.changeGrep( );
app.findGrepPreferences = app.changeGrepPreferences = null;
alert("Done [" + F + "]")
(^/) The Jedi
Copy link to clipboard
Copied
Page = Strona - without "s" at the end - probably should have been "~S" as it's GREP.
Copy link to clipboard
Copied
Thank You very much! I am very grateful for the work you have done.