Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Default browser:

Posted on 1999-07-28
8
Medium Priority
?
215 Views
Last Modified: 2010-11-30
How do I shell a user's default browser and go to a spacific page I specify?
0
Comment
Question by:rtcomp
[X]
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
  • 4
  • 3
8 Comments
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 400 total points
ID: 1528094

Opening a browser to your homepage

You can use code like the following to open a browser to your homepage.
Modify filenames, paths, and URLs as necessary to match the values on your
system.

Dim FileName As String, Dummy As String
Dim BrowserExec As String * 255
Dim RetVal As Long
Dim FileNumber As Integer
Const SW_SHOWNORMAL = 1 ' Restores Window if Minimized or

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

Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" _
(ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As _
String) As Long
'<Code> ---------

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 a browser"

  Else
    RetVal = ShellExecute(frmMain.hwnd, "open", BrowserExec, _
      "www.myurl.com", Dummy, SW_SHOWNORMAL)
    If RetVal <= 32 Then        ' Error
      Msgbox "Web Page not Opened"
    End If
  End If

Kill FileName  ' delete temp HTML file
0
 
LVL 7

Expert Comment

by:kamall
ID: 1528095
rtcomp,
Here is a *superior* one-line code!!!:

x = Shell("start http://www.microsoft.com")

MikeP,
Isn't it superior? :-)
0
 
LVL 7

Expert Comment

by:kamall
ID: 1528096
rtcomp,
If you like my code, can I have the points? (If you dont mind MikeP...).
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rtcomp
ID: 1528097
Exactly what I was looking for.

Thanks.
0
 
LVL 7

Expert Comment

by:kamall
ID: 1528098
rtcomp,
Which one of the two codes?
0
 

Author Comment

by:rtcomp
ID: 1528099
Ok, they both did the same thing, kamall's code was less then MikeP. I allready execpted MikeP's answr but if you would like kamall I will resubmit a ? and then you can recive the same ammount of points also I no one objects.
0
 

Author Comment

by:rtcomp
ID: 1528100
Ooooops, if no one objects?
0
 
LVL 7

Expert Comment

by:kamall
ID: 1528101
Thank you very much rtcomp for your offer.
It will be very kind of you to do so.
Thanks again.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…
Suggested Courses

715 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