Inserting Links made easy!!!
July 20 2006 11:25:40 PM
Add/Read Comments [27]
For this week's "Show-n-Tell Thursday" entry, I wanted to share a really great tool that I stumbled upon here at work. The main credit goes to IBMers Heiko Fischer and Laurence Marks for creating most of this code and working with me to share it will all of you.
In a previous tip, Creating links to a web page, I explained how you can create "URL Hotspots" in Notes to link to a web page. While this works well (and gives you a lot of power to use computed formulas!), it requires several steps and entering the URL into the Properties Box which is not that user friendly. Today's tip provides a simple alternative.
We are going to create a toolbar icon...
which when pressed will prompt you to enter the text for your link...
followed by a prompt for the link itself...
and finally you press either Space or Enter on your keyboard when you see the following dialog box...
and the link will be inserted into the document you are creating.
Note: You may see a MS-DOS window briefly appear and disappear, this is expected, don't worry.
Here are the steps to create the "Insert Hyperlink" toolbar icon.
1. Save the file hyperlink.gif
2. Select the following text and copy it to your clipboard: (UPDATE 2, July 27:Removed the code for pattern matching in the URL.)
lt := @Prompt([OkCancelEdit]; "Create Link"; "Please provide a link text:"; "Link");
@If(@Contains(lt; "<")|@Contains(lt; ">")|@Contains(lt; "|"); @Return(@Prompt([Ok]; "Create Link"; "Invalid character(s) in link text - aborted!")); @Set("lt"; @ReplaceSubstring(lt; "/"; "^/")));
ln := @LowerCase(@Trim(@Prompt([OkCancelEdit]; "Create Link"; "Please provide an URL:"; "http://")));
@Set("ln"; @ReplaceSubstring(ln; "/"; "^/"));
linkhtml := "^<html^>^<a href='"+ln+"'^>"+lt+"^<^/a^>^<^/html^>";
@Do(@Command([Execute]; "cmd.exe"; "\" /c echo "+linkhtml+">link.htm");
@Prompt([Ok];"Pause";"Press Space or Enter to continue and create the link.");
@PostedCommand([FileImport]; "HTML"; "link.htm");
@PostedCommand([Execute]; "cmd.exe"; "\" /c del link.htm"))
3. From the Notes menus select "File - Preferences - Toolbar Preferences..."
4. In the resulting "Toolbar Preferences" dialog box, on the left hand side click "Customize"
5. Click "New - Button"
6. In the resulting "Edit Toolbar Button" dialog box, enter text you want for the button caption and popup help, and then in the formula field paste in the text you copied above.
7. Click on "Change Icon". This brings you to the "Insert Image Resource" dialog box.
8. Click on "New".
9. Select the "hyperlink.gif" file that you saved above, and click Open. Click on "Ok" to close the "Insert Image Resource" dialog box.
10. Click on "OK" to close the "Edit Toolbar Button" dialog box.
11. You will now see the new icon on the Toolbar Contents preview. If you would like you can leave it where it is, personally I like to move it to the far left using the "Left" Reorder button. Click on "Save Toolbar" and then "OK"

