This is a brief post about using Application.FollowHyperlink in your databases.
The Problem With FollowHyperlink
I used to use Application.FollowHyperlink because it was so very simple to use to start e-mails, open files, launch a URL, …
Private Sub cmd_StartEmail_Click()
If IsNull(Me.EmailAddress) = False Then Application.FollowHyperlink Me.EmailAddress
End Sub
until I started getting the dreaded security prompts
The Fix
I decided to try an Web Developer’s code to FollowHyperlink and I was happy to see it resolved this issue. No more security prompts, no more Error 490 – Cannot open the specified file.
So What’s The Trick?
Simply add the protocol as a prefix to the e-mail address, files, url (usually already the case).
In the case of an e-mail address, so starting an e-mail, we need to prefix the e-mail address with mailto://.
A Concrete Example
Instead of :
Application.FollowHyperlink "someone@somewhere.com"
we want to do:
Application.FollowHyperlink "mailto://someone@somewhere.com"
Adapting Our Code
If we take the original code and modify it accordingly, we would get something like:
Private Sub cmd_StartEmail_Click()
Dim sEmail As String
Const MAILTO_PREFIX = "mailto://"
If IsNull(Me.EmailAddress) = False Then
sEmail = Me.EmailAddress
If left(sEmail, Len(MAILTO_PREFIX)) <> MAILTO_PREFIX Then sEmail = MAILTO_PREFIX & sEmail
Application.FollowHyperlink sEmail
End If
End Sub
It’s that simple. Now, FollowHyperlink works as it used to and should. Why Microsoft didn’t make FollowHyperlink automatically do this based on key syntax (elements following RegEx patterns) is anyone’s guess, but at least a simple solution exists.
But Wait, There Are More Protocols!
So, my main goal today was to address the e-mail issue, but there are numerous other protocols that can be implemented depending on what type of ‘link’ you are trying to ‘Follow’. The most common probably being:
- ftp
- file
- http
- https
- mailto
There are even application specific protocols you can utilize:
- skype
A Concrete Web URL Example
So doing:
Application.FollowHyperlink "www.devhut.net"
won’t work, but:
Application.FollowHyperlink "https://www.devhut.net"
will!
All this to say, you should prefix your links with the proper protocols and FollowHyperlink will stop harassing you with security messages, and refuse to open the links.
File/Document Example
Just like with the e-mail address code above, we can do the same for any other protocol, the most common being files, obviously. Thus, we could do:
Private Sub cmd_OpenFile_Click()
Dim sFileLink As String
Const FILE_PREFIX = "file://"
If IsNull(Me.FileLink) = False Then
sFileLink = Me.FileLink
If left(sFileLink, Len(FILE_PREFIX)) <> FILE_PREFIX Then sFileLink = FILE_PREFIX & sFileLink
Application.FollowHyperlink sFileLink
End If
End Sub
where Me.FileLink is a control housing the path and filename of the file to launch.
Protocol Arguments
What is also useful is that various protocol (see below) make various arguments available.
In the case of mailto:// we have arguments such as:
- subject – define the e-mail subject line
- cc – define the CC recipient(s)
- bcc – define the BCC recipient(s)
- body – define the e-mail body content
You can learn more about these by reviewing:

A Basic E-mail Example Using Arguments
A very quick example of using FollowHyperlink to initialize an e-mail while specifying the recipient, CC, subject and body would be:
Application.FollowHyperlink "mailto://someone@somewhere.com?subject=Testing&cc=someonelse@somewhereelse.org&body=Testing"
Also note, in the particular case of mailto://, since this is web based content, you need to encode the subject and body properly, but that is well beyond the context of the present post.
A Few Resources on the Subject

Syntax





The invaluable Allen Browne had already written something about that in 2008.
http://allenbrowne.com/func-GoHyperlink.html
Indeed. I had forgotten about that article. Anything Allen Browne did was exceptional! Such a loss that he stepped away from all things Access.
I used to use that very function, and recommend it, but hit a wall with it with one of my clients.
The one issue I can remember was that it couldn’t handle something like: GoHyperlink “www.devhut.net”, as it needs the http:// or https:// prefix. Then again, if you are providing the prefix, you shouldn’t have any issues with FollowHyperlink in the first place.
At the time, I didn’t have the skills to troubleshoot the code to fix the issue, perhaps I should take another look. That said, the above is substantially simpler and works, so now people have 2 options to consider.
Good stuff!
For me, “file:/” – that is, with only one backslash instead of 2 or 3, did the trick