|
-
Apr 25th, 2004, 08:20 AM
#1
Thread Starter
Lively Member
Command Button driven hyperlinks
Simple question here.
I have a command button. I would like it to simulate a hyperlink. Hence I want to code a web page address, and it would move to that web page address.
Is there a simple method of doing this. I do not want to add extra references to my project. Or code for the opening of the web page editor.
I like the hyperlink concept, where the system opens either a web broswer or an email depending on the address stored.
- My help files are all done in html. I want to incorporate a HELP button in my application that would open my files in IE or whatever browser the user has installed on his system.
-----
#VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP
I miss my VIC 20.
Never should have upgraded to my commodore 64. ...
-
Apr 25th, 2004, 07:47 PM
#2
Here you go. To do an open in the deault email client substitute
the web address with the format of "mailto:[email protected]".

VB Code:
Option Explicit
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
Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
MousePointer = vbHourglass
ShellExecute Me.hwnd, vbNullString, ByVal "http://www.vbforums.com", vbNullString, "C:\", SW_SHOWNORMAL
MousePointer = vbNormal
End Sub
Private Sub Form_Load()
Command1.Caption = "Help"
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 25th, 2004, 10:02 PM
#3
Thread Starter
Lively Member
me.hwnd ?
I get a compile error. Method or data member not found.
What is your "me"? Are you running this from a form? Are you putting any of your code in a class module?
-----
#VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP
I miss my VIC 20.
Never should have upgraded to my commodore 64. ...
-
Apr 26th, 2004, 12:17 AM
#4
Excel VBA version.
VB Code:
Option Explicit
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
Const SW_SHOWNORMAL = 1
Public Sub Command1_Click()
Application.Cursor = xlWait
ShellExecute Application.hwnd, vbNullString, ByVal "http://www.vbforums.com", vbNullString, "C:\", SW_SHOWNORMAL
Application.Cursor = xlDefault
End Sub
Private Sub Workbook_Open()
Command1.Caption = "Help"
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 26th, 2004, 06:31 PM
#5
Thread Starter
Lively Member
Thanks !
I got it working in XL02.
I XL97, I get a object not supported message box in response to your application.hwnd command.
Humm, still looking for a a code routine that is universal to all Excel versions. There must have been a quick and easy way to reference a web page in 97. Hyperlinks can do it so easily so we must be able to code hyperlinks. Any suggestions...
-----
#VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP
I miss my VIC 20.
Never should have upgraded to my commodore 64. ...
-
Apr 26th, 2004, 10:43 PM
#6
The application.name property should be available in Excel 97. So
this will work for 97+
2000 POSTS!!!
VB Code:
Option Explicit
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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Const SW_SHOWNORMAL = 1
Public Sub Command1_Click()
Dim lHwnd As Long
Application.Cursor = xlWait
lHwnd = FindWindow("XLMAIN", "Microsoft Excel - " & ActiveWorkbook.Name)
ShellExecute lHwnd, vbNullString, ByVal "http://www.vbforums.com", vbNullString, "C:\", SW_SHOWNORMAL
Application.Cursor = xlDefault
End Sub
Private Sub Workbook_Open()
Command1.Caption = "Help"
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 26th, 2004, 11:39 PM
#7
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|