Select hyperlinks

13 views
Skip to first unread message

Paul Marriner

unread,
Oct 1, 2016, 11:48:44 AM10/1/16
to indesign-talk
I have a document with numerous page numbers, some are hyperlinks, some not. However there is no visual clue which is which. Is there a grep search that could add a new character style to those that are, or aren't, hyperlinks?

Paul 

Jean-Claude Tremblay

unread,
Oct 1, 2016, 12:07:01 PM10/1/16
to indesi...@googlegroups.com
No need for GREP…

- Create a character style to highlight the hyperlink
- Selection the ALL the Hyperlinks inside the Hyperlinks panel
- Choose Edit Hyperlink in the panel option
- Pick your character style to be applied for the hyperlinks

JC

On Oct 1, 2016, at 11:48 AM, Paul Marriner <flyti...@gmail.com> wrote:

I have a document with numerous page numbers, some are hyperlinks, some not. However there is no visual clue which is which. Is there a grep search that could add a new character style to those that are, or aren't, hyperlinks?

Paul 

--
You received this message because you are subscribed to the Google Groups "InDesign talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to indesign-tal...@googlegroups.com.
To post to this group, send email to indesi...@googlegroups.com.
Visit this group at https://groups.google.com/group/indesign-talk.
For more options, visit https://groups.google.com/d/optout.

Michael Brady

unread,
Oct 1, 2016, 12:27:54 PM10/1/16
to indesi...@googlegroups.com
Jean-Claude wrote:

> No need for GREP…
>
> - Create a character style to highlight the hyperlink
> - Selection the ALL the Hyperlinks inside the Hyperlinks panel
> - Choose Edit Hyperlink in the panel option
> - Pick your character style to be applied for the hyperlinks

The Character Style for Hyperlink should already be there. ID creates it when you make a new hyperlink or ID imports it if the text already has a hyperlink. I just edit the CS attributes by changing the color to None and turning of the underline.

Michael Brady

unread,
Oct 1, 2016, 12:30:58 PM10/1/16
to indesi...@googlegroups.com

> On Oct 1, 2016, at 12:27 PM, Michael Brady <mich...@michaelbradydesign.com> wrote:
>
> I just edit the CS attributes by changing the color to None

Oops. That won’t work! Change the color to black and turn off the underline.


| | | | | | | | | | | | | | | | |
Michael Brady



Paul Marriner

unread,
Oct 1, 2016, 2:25:26 PM10/1/16
to indesign-talk
Thanks JC. I had a bit of brain-fade. Unfortunately being able to do that didn't solve my main problem.

Kasyan Servetsky was kind enough to write me a script to add hyperlinks to page numbers in a concordance. Unfortunately I didn't make clear that many of the page numbers are repeated and thus the script only adds a hyperlink to one instance of a page number. In the script that follows the second and any subsequent occurrence fails at line 43 (source = doc.hyperlinkTextSources.add(sourceTextRef);, or at least in that section. Changing the character style of the non-linked page numbers in the concordance and editing the script got me nowhere. Can anyone modify the following script to overcome the problem?

Paul

/* Copyright 2016, Kasyan Servetsky
September 29, 2016
Written by Kasyan Servetsky
//======================================================================================
var set, doc,
count = 0,
scriptName = "Make hyperlinks";

PreCheck();

//===================================== FUNCTIONS  ======================================
function Main() {
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = "\\d+";
app.findGrepPreferences.appliedCharacterStyle = "Pg Number";
var foundItems = doc.findGrep(true);
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;

if (foundItems.length == 0) ErrorExit("No page numbers were found in the current document.", true);
for (var i = 0; i < foundItems.length; i++) {
try {
var sourceTextRef = foundItems[i];
MakeHyperlink(sourceTextRef);
}
catch(err) {
$.writeln(err.message + ", line: " + err.line);
}
}
var report = count + " hyperlink" + ((count == 1) ? " was" : "s were") + " created.";
alert("Finished. " + report, scriptName);
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
function MakeHyperlink(sourceTextRef) {
var source, destination, hyperlink,
pageNum = sourceTextRef.contents,
obj = GetPage(pageNum);
if (obj != null) {
source = doc.hyperlinkTextSources.add(sourceTextRef);
destination = obj.docDest.hyperlinkPageDestinations.add(obj.page);
hyperlink = doc.hyperlinks.add(source, destination, {name: "Page_" + pageNum});
if (hyperlink.isValid) {
count++;
}
}
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
function GetPage(pageNum) {
var obj = null;
for (var i = 0; i < app.documents.length; i++) {
if (app.documents[i].pages.itemByName(pageNum).isValid) {
obj = {page: app.documents[i].pages.itemByName(pageNum), docDest: app.documents[i]};
break;
}
}
return obj;
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
function PreCheck() {
if (app.documents.length == 0) ErrorExit("Please open a document and try again.", true);
doc = app.activeDocument;
if (!app.activeDocument.saved) ErrorExit("The current document has not been saved since it was created. Please save the document and try again.", true);
Main();
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
function ErrorExit(error, icon) {
alert(error, scriptName, icon);
exit();
}

On Sat, Oct 1, 2016 at 1:06 PM, Jean-Claude Tremblay <tremb...@videotron.ca> wrote:
No need for GREP…

- Create a character style to highlight the hyperlink
- Selection the ALL the Hyperlinks inside the Hyperlinks panel
- Choose Edit Hyperlink in the panel option
- Pick your character style to be applied for the hyperlinks

JC
On Oct 1, 2016, at 11:48 AM, Paul Marriner <flyti...@gmail.com> wrote:

I have a document with numerous page numbers, some are hyperlinks, some not. However there is no visual clue which is which. Is there a grep search that could add a new character style to those that are, or aren't, hyperlinks?

Paul 

--
You received this message because you are subscribed to the Google Groups "InDesign talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to indesign-talk+unsubscribe@googlegroups.com.

To post to this group, send email to indesi...@googlegroups.com.
Visit this group at https://groups.google.com/group/indesign-talk.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "InDesign talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to indesign-talk+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages