Solved

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

Posted on 2007-03-30
6
648 Views
Last Modified: 2010-08-05
Expert Gurus
How do I change it to open a new window everytime?
 Please let me know.
 
Many Thanks

Ted


        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
0
Comment
Question by:tcalbaz
  • 2
  • 2
  • 2
6 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18826346
Well that depends...

What is in "NavTo"?
0
 
LVL 1

Author Comment

by:tcalbaz
ID: 18826443
Nav_to is the URL.

Ted
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 250 total points
ID: 18826835
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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 18828041
That does means hardcoding IE as webbrowser.

When you say new window, is it opening in a new tab sometimes ?  IE7 / FireFox2 ?
0
 
LVL 32

Assisted Solution

by:Robberbaron (robr)
Robberbaron (robr) earned 250 total points
ID: 18828056
see "How ShellExecute Determines Whether to Start a New Instance" in http://support.microsoft.com/kb/224816

example from MS is slightly different in that they dont use null for some reason.
   Dim r As Long
   r = ShellExecute(0, "open", "http://www.microsoft.com", 0, 0, 1)
0
 
LVL 1

Author Comment

by:tcalbaz
ID: 18828830
IdleMind
Thanks for the solution.

robberbaron
Very insightful and useful article.

I have split the points
Thank you

Ted
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library 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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now