Improve company productivity with a Business Account.Sign Up


Hyperlink in VB6

Posted on 2014-01-30
Medium Priority
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 400 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 28

Expert Comment

ID: 39822570
Try using "open" command instead of default (vbNullString)
 Dim r As Long
 r = ShellExecute(0, "open", "", 0, 0, 1)
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.


Author Comment

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

Do have any other suggestions.

Thank you
LVL 28

Assisted Solution

Ark earned 1600 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As a person who answers a lot of questions, I often see code that could be simplified, made easier to read, and perhaps most importantly made easier to maintain if the code was modified to use the Select Case statement. This article explains how to…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

595 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