Internet shortcuts in application

Posted on 1999-07-03
Medium Priority
Last Modified: 2010-05-02
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.
Question by:Caggs
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 1521691
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: http://www.site.com)", 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

Author Comment

ID: 1521692
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?

Expert Comment

ID: 1521693
I think FindExecutable is an API.
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.


Author Comment

ID: 1521694
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?

Author Comment

ID: 1521695
Adjusted points to 75

Author Comment

ID: 1521696
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 caggs@morgan.net.au

thanx again anyway.....your input was appreciated

Accepted Solution

razorzej earned 210 total points
ID: 1521697
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", "http://www.vbcode.com", vbNull, vbNull, 3) ' Maximised window
End Sub

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


Hope that helps.


Author Comment

ID: 1521698
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

Featured Post


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

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

719 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