Locate and open existing Internet Explorer Web Page

Joined
Nov 22, 2019
Messages
5
Office Version
  1. 2016
Platform
  1. Windows
G'day,

I am trying to quickly locate and see an internet explorer window which has already been opened . But I can not seem to make my vba code to open the existing web page. Any assistance on this challenge would be appreciated. Thank you

Sub Test()

Dim shell_application As Object
Dim open_window As Object
Dim ie As Object

Set shell_application = CreateObject("shell.application")

For Each open_window In shell_application.Windows

If TypeName(open_window.document) = "HTMLDocument" Then
Set ie = open_window

Exit For
End If

Next

If ie Is Nothing Then
MsgBox "did not find internet window"

Else
MsgBox "found the page, now navigating"
ie.navigate "google"


With ie
.Height = 600
.Width = 1900
.Top = 373
.Left = 25
.Visible = True
.Toolbar = False
.StatusBar = True
.MenuBar = False

End With

End If

Set ie = Nothing



End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I just worked it out thank you
Sub Example()

Dim myshell
Dim myexplorerwindow
Dim foundexplorerwindow
Dim explorercount
Set myshell = CreateObject("shell.application")
Set foundfoundexplorerwindow = Nothing

Dim dtrparth

strparth = "C:\windows"

For Each myexplorerwindow In myshell.Windows
On Error Resume Next
If UCase(myexplorerwindow.document.Folder.self.Path) = UCase(strPath) Then
Set foundexplorerwindow = myexplorerwindow
Exit For
End If
On Error GoTo 0
Next


If foundexplorerwindow Is Nothing Then
explorercount = myshell.Windows.Count
'myshell.explorer "c:\"
myshell.Open strPath
Do Until myshell.Windows.Count > explorercount
DoEvents
Loop

For Each myexplorerwindow In myshell.Windows
On Error Resume Next
If UCase(myexplorerwindow.document.Folder.self.Path) = UCase(strPath) Then
Set foundexplorerwindow = myexplorerwindow
Exit For
End If
On Error GoTo 0
Next

End If
foundexplorerwindow.Width = 1900
foundexplorerwindow.Height = 600
foundexplorerwindow.Left = 25
foundexplorerwindow.Top = 373
foundexplorerwindow.Visible = True


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,794
Members
449,048
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top