Macro/VB UserFrom - Click Button, Open Browser and got to URL from textbox

stevefisher85

New Member
Joined
Jan 14, 2016
Messages
5
Hello,

Wondering if anyone can help me? I have a UserForm that contains a number of text boxes. One of those text boxes contains a URL. I want to find a way I can either double click the text box, or click a command button, which will open Internet Explorer and navigate to the URL contained within the textbox.

I have searched and found the below code which people say is working for them but is bugging for me at the .HyperlinkAddress = Me!txtURL line



Code:
Private Sub cmdGo_Click()

    Dim ctl As CommandButton

    Set ctl = Me!cmdGo

     If Len(ctl & vbNullString) > 0 Then

         With ctl

             .HyperlinkAddress = Me!txtURL

             .Hyperlink.Follow

         End With

     End If

End Sub


Any help on this would be appreciated. Thanks
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
That doesn't look like Excel VBA code to me, looks more like Access especially with the Me! syntax.

Anyway, in Excel we can use the FollowHyperlink method of the workbook.

Something like this.
Code:
ThisWorkbook.FollowHyperlink txtURL.Value
 
Upvote 0
You are absolutely spot on. Complete oversight trying to find a solution!! Silly mistake. Will give that a go. Thanks for the help :)
 
Upvote 0

Forum statistics

Threads
1,216,025
Messages
6,128,341
Members
449,443
Latest member
Chrissy_M

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top