Hyperlink in VB6

Posted on 2014-01-30
Last Modified: 2014-02-05
I use the following to make hyperlink in vb6 :

' function declaration for hyperlink
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

' click_event
ShellExecute Me.hwnd, vbNullString, "http://SomeWebPage", vbNullString, vbNullString, 1

I am able to open the webpage if I set the default browser to IE9 or FF26.0

However, I could not open any webpage if I set Google Chrome as the default browser

Any suggestions?

Thank you
Question by:rohaya
  • 6
  • 2

Assisted Solution

DEVLitehouse earned 100 total points
ID: 39821873
It looks like some other people have had the same problem. Here's a link to a similar question, with working code:

Good luck!

Author Comment

ID: 39822039
Ok. The work around code is in C. Could you possible translate it to vb6. Thanks.
LVL 27

Expert Comment

ID: 39822570
Try using "open" command instead of default (vbNullString)
 Dim r As Long
 r = ShellExecute(0, "open", "", 0, 0, 1)

Author Comment

ID: 39822781
Thank you for the suggestion. But still could not display webpage.

Do have any other suggestions.

Thank you
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

LVL 27

Assisted Solution

Ark earned 400 total points
ID: 39822859
Private Sub Command1_Click()
    Dim url As String, browser As String
    url = ""
    browser = GetDefaultBrowser
    If InStr(1, browser, "chrome", vbTextCompare) > 0 Then
       Shell browser & " -url " & url
       r = ShellExecute(0, "open", url, 0, 0, 1)
    End If
End Sub

Private Function GetDefaultBrowser() As String
   Dim oShell As Object
   Set oShell = CreateObject("")
   GetDefaultBrowser = Split(oShell.RegRead("HKEY_CLASSES_ROOT\HTTP\shell\open\command\"), Chr(34))(1)
End Function

Open in new window


Author Comment

ID: 39823447
I gave a response this morning but it seemed that it didn't stay here.

I step through the code and it executed the Shell browser.

However, still same thing happening.

Thank you for your effort.

Accepted Solution

rohaya earned 0 total points
ID: 39825604
Hello all,

The following works for IE, FF and Chrome :

Shell "explorer"

Thank you.

Author Comment

ID: 39825610

Author Closing Comment

ID: 39835106
Code works

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now