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


HELP!! - Opening Browser in a NEW Window

Posted on 1999-07-21
Medium Priority
Last Modified: 2012-05-04
in visual basic
is there anyway to open the default browser in a NEW window?
instead of opening in an already open window [if there is one open].
please email me at:
Question by:irsnort
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

Accepted Solution

JaganMohan earned 800 total points
ID: 1526546
Try this code
Option Explicit
Const SW_SHOWNORMAL = 1 ' Restores Window if Minimized or

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 Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" _
(ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As _
String) As Long
Private Sub Command1_Click()
    Dim FileName As String, Dummy As String
    Dim BrowserExec As String * 255
    Dim RetVal As Long
    Dim FileNumber As Integer
    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>" ' 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"

        RetVal = ShellExecute(Me.hwnd, "Open", BrowserExec, _
          "", Dummy, SW_SHOWNORMAL)
        If RetVal <= 32 Then ' Error
          MsgBox "Web Page not Opened"
        End If
      End If

    Kill FileName ' delete temp HTML file
End Sub

Author Comment

ID: 1526547
thanks, what i was lookin for
im using vb3 and forgot to add that but ive changed the code a lil bit and its what i need
thanks agian

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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

722 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