Solved opening a textbox hyperlink in a browser (1 Viewer)

neuroman9999

Member
Local time
Today, 08:21
Joined
Aug 17, 2020
Messages
827
I did not get help for this elsewhere folks, so I wonder, does anyone here have an idea about this?

From what I can see this is not very consistent about Excel. I would like to open a URL in a browser window. the URL val is sitting in a form textbox, and the double click event of the box is this:
Code:
Private Sub txtdoc_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim url As String
    url = frmmain.txtdoc
    ActiveWorkbook.FollowHyperlink Address:=url
End Sub
and I get the errors in the attached images. The first image (#1) is the error that occurs when it first breaks. If I try to run it again, at the time it is broken, I get a new error, shown in image #2. I have also tried this as a formula thrown into the box at another point in the code where I am putting the URL in it currently:
Code:
frmmain.formulaR1C1 = "=hyperlink(" & """" & "www.google.com" & """" & ")"
I have also tried to add TRUE to the ""new window"" arg and that does no good.

Is all this something that I have done perhaps? The textbox is enabled and not locked. I realize that both errors are saying that I should be opening a file, but I just read 3 different articles on the web that claim this method should automatically follow internet URLs and know what to do automatically. I guess one question I have NOT asked is.....does that actual string that sits in the ""url"" var have to be an actual hyperlink produced by Excel? Is it now currently just text in the textbox.

thanks.

1.jpg



2.jpg
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:21
Joined
May 7, 2009
Messages
19,169
i think you do not need to add a reference to the userform:
Code:
Private Sub txtdoc_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim url As String
    url = [txtdoc]
    ActiveWorkbook.FollowHyperlink Address:=url
End Sub
 

neuroman9999

Member
Local time
Today, 08:21
Joined
Aug 17, 2020
Messages
827
@arnelgp , thanks for the contribution. I did not think your change would result in success, and it did not. Tried it. I'm not sure what the issue actually is, but I don't think relative vs. literal references is it. Got the same 2 errors as previously shown. I'm kind of lost here. This is exactly why I don't like working office products, to be honest with you guys. I've run into issues like this for 20+ years. If I did this same kind of referencing code in say, for example, Python, this would not happen. :(
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:21
Joined
May 7, 2009
Messages
19,169
you need to add https to it.
see this sample.
 

Attachments

  • openHyperLink.zip
    17.8 KB · Views: 221

neuroman9999

Member
Local time
Today, 08:21
Joined
Aug 17, 2020
Messages
827
LOL! I can't believe it! thank you for bringing that to my attention, arne. I am seriously disappointed that Excel can't tell the difference. so, issue solved. thanks much. enjoy your weekend.
 

Users who are viewing this thread

Top Bottom