Link to home
Start Free TrialLog in
Avatar of Jambyte
JambyteFlag for United States of America

asked on

Open New Internet Explorer Window

how can i programmatic browse to a specific web page in a NEW Internet Explorer window even if the user has there IE settings set to reuse IE windows?
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

I use this code, which opens a new IE for me, even as i have configured to reuse IE windows:

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

Private Sub Navigate(ByVal NavTo As String)
  Dim hBrowse As Long
  hBrowse = ShellExecute(0&, "open", NavTo, "", "", SW_SHOW)
End Sub


CHeers
Avatar of priya_pbk
priya_pbk

try this:

In windows 2000:-

Privat Sub command1_click()
Call Shell("C:/Program Files/Internet Explorer/iexplore.exe https://www.experts-exchange.com", vbNormalFocus)
End Sub

In others(like windows NT) etc

Privat Sub command1_click()
Call Shell("c:/program Files/Plus!/Microsoft Internet/iexplore.exe https://www.experts-exchange.com", vbNormalFocus)
End Sub

Hope this helps!

-priya


Avatar of Jambyte

ASKER

angelIII, your code seems to be the most elegent but it doesn't open a new window if reuse current IE window is enabled in windows xp IE6.

priya_pbk, is there a way to make new window be in front, be active, or have focus know what i mean?
Actually speaking, I did not have a good read at your question. I had just read the headline qt in the main page.

Again, the above code was for opening IE programatically thru vb (which i thought you wanted)!


if so, change the second parameter to "vbMinimizedFocus" instead of "vbNormalFocus", will this help!

-priya
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate strURL
I found this code in Microsoft's Knowledge Database some time ago and I use it quite a bit. It opens a new browser window even if others are open.

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q174156

Give it a try...

Private Const SW_SHOW = 5 ' Displays Window in its current size and position
Private Const SW_SHOWNORMAL = 1 ' Restores Window if Minimized or Maximized

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, 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"
      Else
          RetVal = ShellExecute(Me.hwnd, "open", BrowserExec, _
            "www.microsoft.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
Hi Jambyte,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

    *** NOTE: I thought that angelIII's techniqye should work, but if it doesn't than maybe AzraSound's  will also fail.  Can anyone say for sure?

Jambyte, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
Avatar of SpideyMod
SpideyMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial