Copy link to clipboard
Copied
Hi there,
Using the following (trimmed down)...
app.findGrepPreferences.findWhat = "FredBloggs";
var myFound = app.activeDocument.findGrep();
... I'm able to find an instance of the word I'm looking for.
The text in question has a Hyperlink Text Anchor on it in the InDesign document.
I've listed all the properties of myFound[0] but can't see anything to do with hyperlinks/anchors etc. Have I missed something or isn't that property available?
Please can someone point me in the right direction.
Thanks in advance.
2 Correct answers
You can look at the findHyperlinks method on the text, this will give you a list of all the hyperlinks in the text. One interesting discussion on this topic can be accessed from the link below
https://community.adobe.com/t5/indesign-discussions/finding-hyperlinks/m-p/1767663#M268273
-Manan
Hyperlinks are not accessible via GREP, I don't believe. Building off your script, you can use @Manan Joshi's solution:
app.findGrepPreferences.findWhat = "FredBloggs";
var myFound = app.activeDocument.findGrep();
var myHypes, nh, hypeTextSource, anch;
var i = myFound.length;
while(i--) {
myHypes = myFound[i].findHyperlinks();
nh = myHypes.length;
while(nh--) {
hypeTextSource = myHypes[nh].sourceText;
anch = hypeTextSource.insertionPoints[0];
//do something
...
Copy link to clipboard
Copied
You can look at the findHyperlinks method on the text, this will give you a list of all the hyperlinks in the text. One interesting discussion on this topic can be accessed from the link below
https://community.adobe.com/t5/indesign-discussions/finding-hyperlinks/m-p/1767663#M268273
-Manan
Copy link to clipboard
Copied
Thanks for the help Manan, I'll look into findHyperlinks.
Is it possible to access a 'Hyperlink Text Anchor' property for each instance of the findGrep() method above?
Thanks again.
Copy link to clipboard
Copied
Hyperlinks are not accessible via GREP, I don't believe. Building off your script, you can use @Manan Joshi's solution:
app.findGrepPreferences.findWhat = "FredBloggs";
var myFound = app.activeDocument.findGrep();
var myHypes, nh, hypeTextSource, anch;
var i = myFound.length;
while(i--) {
myHypes = myFound[i].findHyperlinks();
nh = myHypes.length;
while(nh--) {
hypeTextSource = myHypes[nh].sourceText;
anch = hypeTextSource.insertionPoints[0];
//do something with the ip
}
}
Faster probably would be to just find the doc's textsources and, if the contents match your find, do something:
var hlts = app.activeDocument.hyperlinkTextSources;
var i = hlts.length;
while(i--) {
if (hlts[i].contents == "FranksBlogg") {
//do something with hlts[i].insertionPoints[0];
}
}
Copy link to clipboard
Copied
Hi there,
Thanks for the help and the code examples.
I should re-read Manan's post again, I'd not looked at the methods available I was too focussed on the properties.
Thank you once again, much appreciated 🙂

