ShellExecute() How do I change it to open a new window everytime?

Expert Gurus
How do I change it to open a new window everytime?
 Please let me know.
Many Thanks


        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 Const SW_SHOW = 1

        Public Sub Navigate(ByVal NavTo As String)
          Dim hBrowse As Long
          hBrowse = ShellExecute(0&, "open", NavTo, "", "", SW_SHOW)
        End Sub
Who is Participating?
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
One way...

Click on Project --> References and check the "Microsoft Internet Controls" entry.

    Public Sub Navigate(ByVal NavTo As String)
        Dim ie As New InternetExplorer
        ie.Visible = True
        ie.Navigate NavTo
    End Sub
Mike TomlinsonMiddle School Assistant TeacherCommented:
Well that depends...

What is in "NavTo"?
tcalbazAuthor Commented:
Nav_to is the URL.

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.

Robberbaron (robr)Commented:
That does means hardcoding IE as webbrowser.

When you say new window, is it opening in a new tab sometimes ?  IE7 / FireFox2 ?
Robberbaron (robr)Connect With a Mentor Commented:
see "How ShellExecute Determines Whether to Start a New Instance" in

example from MS is slightly different in that they dont use null for some reason.
   Dim r As Long
   r = ShellExecute(0, "open", "", 0, 0, 1)
tcalbazAuthor Commented:
Thanks for the solution.

Very insightful and useful article.

I have split the points
Thank you

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.