Solved

Hyperlink in VB6

Posted on 2014-01-30
9
291 Views
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
0
Comment
Question by:rohaya
  • 6
  • 2
9 Comments
 
LVL 3

Assisted Solution

by:DEVLitehouse
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: http://stackoverflow.com/questions/112169/google-chrome-broke-shellexecute

Good luck!
0
 

Author Comment

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

Expert Comment

by:Ark
ID: 39822570
Try using "open" command instead of default (vbNullString)
 Dim r As Long
 r = ShellExecute(0, "open", "http://www.microsoft.com", 0, 0, 1)
0
 

Author Comment

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

Do have any other suggestions.

Thank you
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 27

Assisted Solution

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

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

Open in new window

0
 

Author Comment

by:rohaya
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.
chrome.docx
0
 

Accepted Solution

by:
rohaya earned 0 total points
ID: 39825604
Hello all,

The following works for IE, FF and Chrome :

Shell "explorer http://www.microsoft.com/"

Thank you.
0
 

Author Comment

by:rohaya
ID: 39825610
solved
0
 

Author Closing Comment

by:rohaya
ID: 39835106
Code works
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is about my first experience with programming Arduino.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

864 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

23 Experts available now in Live!

Get 1:1 Help Now