How to open a link with a macro?

Get help using and writing Nisus Writer Pro macros.
Post Reply
Þorvarður
Posts: 248
Joined: 2012-12-19 05:02:52

How to open a link with a macro?

Post by Þorvarður » 2016-03-22 06:23:39

Is it possible to search for a word or string in a link and then, once found, open the link with a macro, i.e. without having to click on it with the mouse?

User avatar
phspaelti
Posts: 912
Joined: 2007-02-07 00:58:12
Location: Japan

Re: How to open a link with a macro?

Post by phspaelti » 2016-03-22 18:29:48

The basic approach will be something like this:

Code: Select all

$term = 'Link'
$doc = Document.active
$found = $doc.text.find $term
if $found
	$link = $doc.text.linkAtIndex $found.location
	$link.activate $doc
else
	prompt 'Sorry. No links with term "' & $term & '" found'
end
Note however that Find will only search the display text for the term, not the link itself. If you wanted to search for words in the links, you'd probably have to write something more complicated.
philip

Þorvarður
Posts: 248
Joined: 2012-12-19 05:02:52

Re: How to open a link with a macro?

Post by Þorvarður » 2016-03-23 04:05:09

This is fine. Thank you, Philip.

Post Reply