![]() |
Tipp 0459
|
Hyperlink folgen (Label auf UserForm)
|
 |
|
Autor/Einsender: Datum: |
|
Angie 24.08.2005 |
|
Entwicklungsumgebung: |
|
Excel 2000 |
|
|
Für heutige Programme ist es schon fast eine Selbstverständlichkeit, mit einem Link auf die eigene Webseite zu verweisen.
Dazu genügt es, die Webseite mit dem Programm zu starten, das mit .htm- oder .html-Dateien verknüpft ist.
Die API-Funktion ShellExecute ist dafür geradezu ideal, da hier mit einem Parameter die Verknüpfung übergeben
und das entsprechende Programm gestartet werden kann.
|
|
Code im Codebereich der UserForm |
|
|
Option Explicit
Private m_blnHyperlink As Boolean
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
Private Sub UserForm_Initialize()
With Me.lblHyperlink
.BackColor = Me.BackColor
.WordWrap = False
.AutoSize = True
.ForeColor = vbBlue
.Font.Bold = False
.Font.Underline = True
End With
End Sub
Private Sub lblHyperlink_Click()
Dim nRetVal As Long
nRetVal = ShellExecute(0, vbNullString, lblHyperlink.Caption, _
vbNullString, vbNullString, vbNormalFocus)
End Sub
Private Sub lblHyperlink_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Not m_blnHyperlink Then
With Me.lblHyperlink
.Font.Bold = True
.ForeColor = vbRed
End With
m_blnHyperlink = True
End If
End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If m_blnHyperlink Then
With Me.lblHyperlink
.Font.Bold = False
.ForeColor = vbBlue
End With
m_blnHyperlink = False
End If
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
|
|
|
|
Die im Download befindliche *.frm-Datei kann für Word und PowerPoint im jeweiligen Programm im VB-Editor importiert werden.
|
|
Windows-Version |
95 |
 |
|
98 |
 |
|
ME |
 |
|
NT |
 |
|
2000 |
 |
|
XP |
 |
|
Vista |
 |
|
Win
7 |
 |
|
|
Anwendung/VBA-Version |
Access 97 |
 |
Access 2000 |
 |
Access XP |
 |
Access 2003 |
 |
Access 2007 |
 |
Access 2010 |
 |
|
Excel 97 |
 |
Excel 2000 |
 |
Excel XP |
 |
Excel 2003 |
 |
Excel 2007 |
 |
Excel 2010 |
 |
|
Word 97 |
 |
Word 2000 |
 |
Word XP |
 |
Word 2003 |
 |
Word 2007 |
 |
Word 2010 |
 |
|
PPT 97 |
 |
PPT 2000 |
 |
PPT XP |
 |
PPT 2003 |
 |
PPT 2007 |
 |
PPT 2010 |
 |
|
Outlook 97 |
 |
Outlook 2000 |
 |
Outlook XP |
 |
Outlook 2003 |
 |
Outlook 2007 |
 |
Outlook 2010 |
 |
|
|
|
Download (18,2 kB)
|
Downloads bisher: [ 803 ]
|
|
|