How to un-minimize an IE window IF it is minimized with VBA?

423 views Asked by At

I am using the following code to interact with an IE window. The code works perfectly IF the window has not been minimized and it just behind the other windows I have opened. If the user has minimized the IE window, then the things I am trying to do with IE do not fire. What can I add to un-minimize the window IF it is minimized. I would preferably like to leave the window in the same state (If the user has it maximized or sized to only cover a portion of the screen).

Public Declare Function SetForegroundWindow Lib "user32" (ByVal HWND As Long) As Long

Dim ie As Object
Dim GetIE As Object
Dim HWNDSrc As Long
Dim sIEURL As String

For Each GetIE In CreateObject("Shell.Application").Windows() 'Loop to find
If (Not GetIE Is Nothing) And GetIE.Name = "Internet Explorer" Then Exit For 'Found!
Next GetIE
GetIE.Visible = True 'Make IE window visible
Set ie = GetIE

HWNDSrc = ie.HWND
SetForegroundWindow HWNDSrc

'some code here



End Sub
0

There are 0 answers