|
|
|
|
|
|
Excel
|
Website Hyperlink on a form
|
|
Ease of Use
|
Easy
|
Version tested with
|
2000, 2002
|
Submitted by:
|
Justinlabenne
|
Description:
|
Using a label on a userform, provide a link to a pre-designated website.
|
Discussion:
|
Maybe on a project you developed you would like the users to know about your website. On a userform, you can provide a quick easy link to it using a label and a bit of code. Or link to any website of your choosing, like vba express.
The attached example provide 3 different formatted labels that you can use to hyperlink to a website of your choosing.
|
Code:
|
instructions for use
|
Option Explicit
Private Sub lblNavigate_Click()
Const szhttp As String = "http://www."
Dim szWebsite As String
szWebsite = Me.lblNavigate.Caption
Dim szValidWebPath As String
szValidWebPath = szhttp & szWebsite
ThisWorkbook.FollowHyperlink szValidWebPath
Unload Me
End Sub
Option Explicit
Sub ShowWebForm()
frmWebNav.Show
End Sub
|
How to use:
|
- Open an Excel Workbook
- Copy the code
- Press Alt + F11 to open the Visual Basic Editor (VBE)
- Select INSERT > USERFORM from the menubar
- Rename the userform: frmWebNav
-
- You will need to add:
- 1 Label = lblNavigate
-
- Double Click on the label
- Paste code into the userform code module
-
- Select INSERT > MODULE from the menubar
- Paste code into the right pane
- Copy the {ShowWebForm} code into the standard module
- Press Alt+Q to return to Excel
- Save workbook before any other changes
|
Test the code:
|
- Go to TOOLS > MACRO > MACROS
- Select {ShowWebForm} from the dialog box
- Press {Run}
- The userform will be displayed
- Click on a label to navigate to the web address listed on the label
|
Sample File:
|
FormLabel_web.zip 10.17KB
|
Approved by mdmackillop
|
This entry has been viewed 183 times.
|
|