Copy link to clipboard
Copied
In the normal InDesign process to create an email hyperlink I do the following:
Copy the email address to be created.
Select the individual's name for the link.
Right-click and select New Hyperlink.
Paste the email address.
This results in a link that shows a person's name, but has the hyperlink in hidden code.
So, clicking on the entry Doe, John would create a new email in the default email application but would not look like an email address.
I'd like to script this, to either copy the email address from the same ID document or from an external list, similarly to a list merge. I have effectively zero experience in scripting.
Has anyone seen such a script or knows a source they can point me toward?
Thanks!
Rich
Copy link to clipboard
Copied
Hi Rich:
We have an InDesign Scripting forum for these sorts of questions. I'll move this over there for you so that you can can an answer to your scripting question.
~Barb
Copy link to clipboard
Copied
Hi Rich,
We would need some mechanism to identify which text is to be hyperlinked, taking que from another question posted on the forum i am taking that identifier to be any text in the document that is between [], after the script is done the brackets would be removed and only the text within it is hyperlinked. The other requirement is how do we feed in the email addresses, we can use a text file with email addresses on a single line, some sample entries for this file could be as follows
mailTo:First@g.com
mailTo:Second@g.com
Once you have added brackets in your document to identify the text to be hyperlinked and created the text file, then run the following code
app.doScript(createHyperLink, ScriptLanguage.javascript, undefined, UndoModes.ENTIRE_SCRIPT, "Email Hyperlink");
function createHyperLink()
{
var fi = new File("/Users/manan/Desktop/abc.txt") //Change to the path of your input file
if(!fi.exists)
{
alert("Input file does not exist")
exit()
}
fi.open("r");
var data = fi.read().split('\n')
app.findGrepPreferences.findWhat = "\\[.*?\\]"
var res = app.documents[0].findGrep(true)
data = data.slice(0, res.length)
while(a = res.shift())
{
a.contents = a.contents.substring(1, a.contents.length - 1)
var source = app.documents[0].hyperlinkTextSources.add(a)
var dest = app.documents[0].hyperlinkURLDestinations.add(data.pop())
app.documents[0].hyperlinks.add(source,dest, {name:a.contents})
}
app.findGrepPreferences = NothingEnum.nothing;
}
P.S. :- This code would work on the whole document, if you need to modify it to work on selected textframe it known i will modify the code to that effect.
-Manan
Copy link to clipboard
Copied
Hi Rich
My Hyperlinker script may be able to help you, depending on the nature of your document. It has a 'custom search' feature that allows you to do a GREP powered find, then optionally add the result to a destination URL. It could be achieved in two different ways, neither of which require any kind of external list:
Cheers
Kal