Cannot Open Hyperlink

Frank123

Registered User.
Local time
Today, 06:44
Joined
Jun 29, 2016
Messages
31
Hi, I'm new to VBA and I have an issue opening up hyperlinks. I have hyperlinks stored in a table and have a button on a form to open each one. I have used the code below on other forms which works great. But now, no hyperlink will open on the form I'm using and I get a run-time error '6' (The internet site reports that the item you requested could not be found). However, when I click on each hyperlink in the table, they open fine. Any help would be greatly appreciated.

Dim strURL1 As String
Dim strURL2 As String
strURL1 = Me.StateRegulations
strURL2 = Replace(strURL1, "#", "")
Application.FollowHyperlink (strURL2)
 
If you have them stored in Hyperlink fields, (which looking at your code you have) then that is probably part of the problem (bizarrely).

If you simply store the link as a text field and open it using application.followhyperlink it will almost certainly work.
 
hyperlink field stores the link
in two parts separated by "#".
the first part is the text that is
displayed on your screen. the
second part is the link to file
or internet site:

gotoSite#www.SomeSite.com#

gotoSite is the one that is displayed
on the screen (in underline), while
www.SomeSite.com is the actual link.


to extract only the link part use
Split():

Application.FollowHyperlink Split(Me.StateRegulation, "#")(1)
 
Awesome!!! Thanks Minty and arnelgp. Both suggestions worked great. I appreciate your fast reply. Have a great day.
 

Users who are viewing this thread

Back
Top Bottom