AnsweredAssumed Answered

How to add a link to a website using a command button in userforms?

Question asked by Advait Pandit on Apr 16, 2020
Latest reply on Apr 16, 2020 by Jim Sculley

Hello, 

I am trying to add a link to a website when a command button ("visit our website") is clicked. I have tried using the following code that was posted on this forum but it doesnt seem to work:

 

Private Sub Link_Click()
Dim link As String

link = "https://www.westfieldfasteners.co.uk"
Call Shell("rundll32.exe url.dll,FileProtocolHandler" & link, vbNormalFocus)
End Sub

 

I have also tried replacing "rundll32.exe url.dll,FileProtocolHandler" with "Explorer.exe" , "MicrosoftEdge.exe" and "Chrome.exe" but it doesn't open anything. I have tried searching for other methods but could not find anything online. 

 

In addition to this, is there a similar way to open an image in a new window by clicking a command button on the userform?

 

Thank You!

Outcomes