decadence
Well-known Member
- Joined
- Oct 9, 2015
- Messages
- 525
- Office Version
- 365
- 2016
- 2013
- 2010
- 2007
- Platform
- Windows
Hi, Is there a way to check if the Internet Explorer is Open/Running, I have searched over and over but can't seem to find a solution.
The Code below is what I have so far, Can someone help Please
The Code below is what I have so far, Can someone help Please
VBA Code:
Option Explicit
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdSHow As Long) As Long
Const SW_SHOWMAXIMIZED = 3
Const URL As String = "http://www.google.co.uk/search?q="
Const GoogleSearch As String = "Microsoft"
Dim IE
Sub SearchInternet()
'Search Internet From Excel
Set IE = CreateObject("InternetExplorer.Application")
''''''''''''Check if Internet is already open and if so add new tab and search in new tab
'IE.Navigate URL & GoogleSearch, CLng(2048)
''''''''''''If Internet Explorer is not open then Open internet explorer and search
IE.Navigate URL & GoogleSearch
Do
If IE.ReadyState = 4 Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop
Do
If IE.Busy Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop
'Do While IE.ReadyState <> 4: DoEvents: Loop
'Do While IE.Busy: DoEvents: Loop
ShowWindow IE.hwnd, SW_SHOWMAXIMIZED
IE.Visible = True
Set IE = Nothing
End Sub