I thought I’d take a quick break from looking at the new features in Visio 2010 and turn to a topic that pops up fairly regularly in newsgroups – Hyperlinks...
Inserting a hyperlink
You can assign hyperlinks to any Shape or Page in Visio by selecting your target shape (or ensuring no shapes are selected if you want to add it to the page) and then clicking Insert / Hyperlinks… on the menubar or using the keyboard shortcut Ctrl+K. This will produce the Hyperlinks dialog, as below, and from here you can click the Browse… button.
From here you can either link to a URL on the web or to a document on your system / network. Clicking Internet Address… will launch your default browser and Local File… a file explorer window. Let’s look at the web link option first.
Linking to the web
Once your browser has opened, navigate to the web page you’re after and then return to the dialog (leaving the browser window open). Visio detects the address and title of the page you navigated to and inserts them in the Address and Description fields respectively. If the address you navigated to included a named anchor tag to a particular location in the page, such as:
…then this will be added to the Sub-address field, minus the hash symbol.
Linking to a file
Adding a hyperlink to a file is pretty similar. The path of the file you select in the explorer window is added to the Address field and its name is added to Description.
If you’re linking to another Visio document you have three more options available to you by clicking the Browse button to the right of the Sub-address field. This button throws up another dialog, where you can set a target page, target shape and zoom level:
Once you’ve set these options, Visio amends the hyperlink by adding the zoom level to the Address, and the Page and Shape names to the Sub-address fields.
Although the Sub-address Browse button only works for Visio documents you can add your own sub addresses for other document types. Excel MVP, Jon Peltier, has a page on his site highlighting how to link to various Office documents. The only difference for Visio is that you don’t need to add the hash symbol as this is taken care of behind the scenes. So, for example, to link to the second page of a Word document, where the normal link would be:
…in Visio, you would just add ‘C:\My Documents\MyDocument.doc’ to the Address field and ‘2’ to the Sub-address field.
A final point about the Hyperlinks dialog, which applies to both web and file links, is that it allows you to add relative paths (using the checkbox). When using this option, the link path is relative to the document’s Hyperlink Base and you can find this under File / Properties / Summary. So, for example – with your document Hyperlink Base set to ‘http://www.bing.com’ if you want to link to the following URL:
…and the Use relative path checkbox is unchecked (ie an absolute path), your Address field will display the full URL as above. However, if you check the box, the Address field will display:
Bear in mind that even though Visio checks the Hyperlink Base as you add each one using the dialog, you don’t get any warning when changing the Base later on, which could potentially leave you with a lot of dead links.
Under the covers
OK, so that’s the standard method covered, but if you open up the ShapeSheet you can see a little more of what’s going on underneath.
Above you can see the Hyperlinks ShapeSheet section with a single row (broken into three parts). All the Hyperlinks dialog is doing is really just writing to ShapeSheet cells and the various parts of the link are accessible independently. As with the missing hash symbol you can see that the ‘?’ character is also removed so that the URL parameters get housed in the ExtraInfo and the main address in the Address cell.
So that feels like a good point to pause. In the next post I’m going to look at how you can construct hyperlinks dynamically based on other data that you have in your shapes and document.