Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

Hyperlink in VB6

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
rohaya
Asked:
rohaya
  • 6
  • 2
3 Solutions
 
DEVLitehouseCommented:
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
 
rohayaAuthor Commented:
Ok. The work around code is in C. Could you possible translate it to vb6. Thanks.
0
 
ArkCommented:
Try using "open" command instead of default (vbNullString)
 Dim r As Long
 r = ShellExecute(0, "open", "http://www.microsoft.com", 0, 0, 1)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
rohayaAuthor Commented:
Thank you for the suggestion. But still could not display webpage.

Do have any other suggestions.

Thank you
0
 
ArkCommented:
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
 
rohayaAuthor Commented:
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
 
rohayaAuthor Commented:
Hello all,

The following works for IE, FF and Chrome :

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

Thank you.
0
 
rohayaAuthor Commented:
solved
0
 
rohayaAuthor Commented:
Code works
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now