frizzell
asked on
Using OIE To Open IE From VB6 App
Using the code below, is there a way to force the opened IE window to have focus? There are multiple menu choices, so the user may open 2 or more IE windows. The first window opens on top, but, if the first window is left open, the subsequent windows open behind the app. Thank you.
Dim strLink As String
Dim strFullLink As String
strLink = "http://intranet/default.aspx"
Dim oIE As New InternetExplorer
With oIE
.Toolbar = False
.MenuBar = False
.Visible = True
.FullScreen = False
.AddressBar = False
End With
Select Case strReport
Case "Misc Report"
oIE.Navigate "http://intranet/default.aspx?Report=MiscReport&Year=2007&Dept=123&Class=XYZ"
Case "Test Report"
strFullLink = strLink & "?Report=" & strReport
strFullLink = strFullLink & "&Year=" & strYear
If strDept <> "" Then
strFullLink = strFullLink & "&Dept=" & strDept
End If
oIE.Navigate strFullLink
Dim strLink As String
Dim strFullLink As String
strLink = "http://intranet/default.aspx"
Dim oIE As New InternetExplorer
With oIE
.Toolbar = False
.MenuBar = False
.Visible = True
.FullScreen = False
.AddressBar = False
End With
Select Case strReport
Case "Misc Report"
oIE.Navigate "http://intranet/default.aspx?Report=MiscReport&Year=2007&Dept=123&Class=XYZ"
Case "Test Report"
strFullLink = strLink & "?Report=" & strReport
strFullLink = strFullLink & "&Year=" & strYear
If strDept <> "" Then
strFullLink = strFullLink & "&Dept=" & strDept
End If
oIE.Navigate strFullLink
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>my computer needs to be rebuilt
So does mine, it works for a few hours then randomly just switches off.
Bad luck, hope you get it sorted soon and it does not cost too much........
So does mine, it works for a few hours then randomly just switches off.
Bad luck, hope you get it sorted soon and it does not cost too much........
ASKER
I've tested your code in my project, and it works well. Now the problem is that each IE window stays on top, so to return to the application the user must drag the window out of the way. Is there a simple way to make the focus return to the application window while still keeping the IE windows open in the background? Thank you.
ASKER
Just to clarify: I want the focus to return to the app when it is clicked, not automatically. As it exists, when a user clicks on the app window, the IE windows stay on top.
Ok so I think I understand how you need it to work, so just a few simple mods.....
Private Sub mnu_MyMenuOption_Click()
zOpenIE "http://MyServer/MyPage.htm"
End Sub
Private Sub zOpenIE(psURL As String)
Dim oIE As New InternetExplorer
With oIE
.ToolBar = False
.MenuBar = False
.Visible = True
.FullScreen = False
.AddressBar = False
End With
oIE.Navigate "http://www.bbc.co.uk"
' force to stay on top
SetWindowOnTop oIE.Hwnd, fsHWND_TOPMOST
DoEvents
' Now we may have to monitor page status but not sure right now.....
' But weshould now relegate the new IEWindow to a normal window
' It will stay on top but allow the app window to become top most
SetWindowOnTop oIE.Hwnd, fsHWND_NOTOPMOST
End Sub
Private Sub mnu_MyMenuOption_Click()
zOpenIE "http://MyServer/MyPage.htm"
End Sub
Private Sub zOpenIE(psURL As String)
Dim oIE As New InternetExplorer
With oIE
.ToolBar = False
.MenuBar = False
.Visible = True
.FullScreen = False
.AddressBar = False
End With
oIE.Navigate "http://www.bbc.co.uk"
' force to stay on top
SetWindowOnTop oIE.Hwnd, fsHWND_TOPMOST
DoEvents
' Now we may have to monitor page status but not sure right now.....
' But weshould now relegate the new IEWindow to a normal window
' It will stay on top but allow the app window to become top most
SetWindowOnTop oIE.Hwnd, fsHWND_NOTOPMOST
End Sub
Woops....
oIE.Navigate psURL
oIE.Navigate psURL
ASKER
The program is now working as I intended. Thank you for all of your coding assistance.
ASKER