hyperlink opens twice

hubcap750

Registered User.
Local time
Today, 12:49
Joined
Jun 27, 2013
Messages
34
Hi all,
I have a form with a textbox with the "LinkedIn" profile address that I want the user to be able to pull up when they click a command button. It works, except that the link opens twice in two tabs in the browser. I've checked over the code for the whole form, and this code is only being run from the click event of the button, so why would it open the same tab twice? Here's the code:

Private Sub cmd_Click()
Dim ctl As CommandButton
Dim txthyper As String

Set ctl = Me!cmd
txthyper = Me!LinkedIn

With ctl
.HyperlinkAddress = txthyper
.Hyperlink.Follow
End With

End Sub
Any ideas?
 
I don't see why it would open twice, but the code seems unnecessarily complicated. Try simply:

Application.FollowHyperlink Me!LinkedIn

The button's hyperlink property isn't filled in, is it? That could be the reason for it opening twice.
 
Neither the button nor the textbox's hyperlink property was filled in, but your code works fine, only opens once. The code was so complicated because I copied it from somewhere else. up until now I haven't used hyperlinks, so thanks very much for helping me simplify things!
 

Users who are viewing this thread

Back
Top Bottom