Hi All,
I create hyperlink by finding http and www in my active document. //Works well
But the problem is, if the url or websites contents coming twice or above then I found error //not able to create hyperlink source with the same name
i.e., www.gmail.com (comes 2 or more time in the document, then the below code is not working fine)
var myDoc = app.activeDocument; app.findGrepPreferences = app.changeGrepPreferences = null; //Find http and www app.findGrepPreferences.findWhat = "(?i)(http|www)\\S+[\\l\\u|\\d]" var myFound1 = myDoc.findGrep(); count = 0 for(k=0; k<myFound1.length; k++) { var myFind = myFound1[k]; var myHyperlinkSource = app.activeDocument.hyperlinkTextSources.add(myFind) var myHyperlinkURLDestination = app.activeDocument.hyperlinkURLDestinations.add(myFind.contents) var myHyperlink = app.activeDocument.hyperlinks.add(myHyperlinkSource, myHyperlinkURLDestination, {name: myFind.contents}) // var myHyperlink = app.activeDocument.hyperlinks.add(myHyperlinkSource, myHyperlinkURLDestination, {name: myFind.contents+count++}) }
Please find the screenshot for your more references.
Please help to find the solution.
Thanks in advance
Beginner_X