Internet shortcuts in application

i was hoping some of you experts could help me with a little problem. i would like to have shortcuts to various sites in my application and i don't really know how to go about it. i would like the user to be able to click particular buttons which will launch their default browser and automatically load up pre-defined url's.
can any of you guys help me? if so it would be greatly appreciated.
thanx for your time.
Who is Participating?
razorzejConnect With a Mentor Commented:
Here is a much simpler solution.

1. Create a standard project.
2. Place a button named "Command1" on the form.
3. Put this code in the form:

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 Sub Command1_Click()
    Dim i As Long
    i = ShellExecute(Me.hwnd, "open", "", vbNull, vbNull, 3) ' Maximised window
End Sub

4. Now, when you click the button, the site "" will load!


Hope that helps.

put a label or a command button on your from and this:

Private Sub Command1_Click()

Dim filename, Dummy As String
Dim BrowserExec As String * 255
Dim RetVal As Long
Dim FileNumber As Integer
      ' First, create a known, temporary HTML file      BrowserExec = Space(255)
      filename = "C:\temphtm.HTM"
      FileNumber = FreeFile                    ' Get unused file number
      Open filename For Output As #FileNumber  ' Create temp HTML file
          Write #FileNumber, "<HTML> <\HTML>"  ' Output text
      Close #FileNumber                        ' Close file
      ' Then find the application associated with it
      RetVal = FindExecutable(filename, Dummy, BrowserExec)
      BrowserExec = Trim(BrowserExec)
      ' If an application is found, launch it!
      If RetVal <= 32 Or IsEmpty(BrowserExec) Then ' Error
          MsgBox "Could not find associated Browser", vbExclamation, "Browser Not Found"
          RetVal = ShellExecute(Me.hwnd, "open", BrowserExec, _
            "put your web page here (like:", Dummy, SW_SHOWNORMAL)
          If RetVal <= 32 Then        ' Error
              MsgBox "Web Page not Opened", vbExclamation, "URL Failed"
          End If
          End If
      Kill filename                   ' delete temp HTML file
End Sub
CaggsAuthor Commented:
thanx for your response tgl

i entered the code u gave me and ran my program, but when i clicked the image that i attached the code to, it came up with a message "compile error - sub or function not defined"
when i clicked ok, the code was presented to me with the word FindExecutable highlighted in the line
"RetVal = FindExecutable(filename, Dummy, BrowserExec)"

with my limited vb knowledge i don't know what to do?

think you cuold help me out again?
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

I think FindExecutable is an API.
CaggsAuthor Commented:
thanx for the comment kdivad

i read up on api's and declared the FindExecutable and ShellExecute api's in my project (which is just a standard exe project) and now when i run the program and click the image which i want to link to a site, i no longer get the compile error messages, however it doesn't launch the browser for some reason. it accepts the click, displays the little arrow with the hourglass(indicating it is processing), sends communication to the web (saw modem activity in tray icon) but does not launch the default browser and display the site...

any ideas on why this is?
CaggsAuthor Commented:
Adjusted points to 75
CaggsAuthor Commented:
thx for the response tgl...

sorry but i have to reject the answer because i couldn't get the code to work. when i click the image i want to link to a site, it accepts the click, displays the little arrow with the hourglass(indicating it is processing), sends communication to the web (saw modem activity in tray icon) but does not launch the default browser and display the site... i left a comment explaining this, hoping u might know why, but it has been two days now without response so i feel i should let some other experts have a go...

if u have any idea why the code didn't work please e-mail me at

thanx again anyway.....your input was appreciated
CaggsAuthor Commented:
thanx very much for the help razorzej...

i tested the code and it worked perfectly...however i have found an even easier way to link to sites from another bulletin board....use the following code....

Shell "start URL", vbHide

You may replace 'URL' with your actual internet address you wish to link to. 'vbHide' causes VB not to display an MS-DOS window when executing Start.Exe.

this statement requires no special declarations either...

however, thanx again for the help.....much appreciated
All Courses

From novice to tech pro — start learning today.