I am having trouble finding an answer to what I think should be a very basic problem. I want to include active hyperlinks in my user form.
The first place I want to use it is on my about screen. I have a text box that contains copyright information, a link to my website, etc. The hyperlink to my site displays but is not clickable.
The other place I want to be able to use a hyperlink is for my help documentation. I want to be able to place a button or a menu option labeled "Help" that when clicked on takes the user to my online documentation.
If anyone can provide some sample code or at least point me to the correct section of the API I would appreciate it.
I currently develop for Photo-Paint and Draw in x7.
Thanks for the help with this. It was enough to point me in the right direction. In case someone in the future is looking for help with this here is a little more detail on what I ended up doing.
Make sure that under Tools->References that you have selected "Microsoft Shell Controls and Automation"
Add a module and insert the following code:
Declare PtrSafe Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" (ByVal hwnd As LongPtr, _ ByVal lpOperation As String, ByVal lpFile As String, _ ByVal lpParameters As String, ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As LongPtrPublic Sub launchBrowser(url As String) ShellExecute 0, vbNullString, url, vbNullString, vbNullString, 5End Sub
Then in the Click event for your label/button/etc just add
launchBrowser "www.google.com"
You should make sure your Windows API declare statements are 64-bit and 32-bit friendly.
#If VBA7 Then Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr #Else Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long #End If
-Shelby