I want to maximize IE by SW_MAXMIZE and then alert the user by prompting a msgbox. But since IE is maxmized, I want to bring Excel to the top by calling setforegroundwindow, but this statement is not working. Please help!
my code:
Public Declare PtrSafe Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Declare PtrSafe Function SetForegroundWindow Lib "user32" (ByVal hwnd As LongPtr) As Long
Public Const SW_MAXIMIZE = 3
sub try()
Set IE = New InternetExplorerMedium
IE.visible = True
apiShowWindow IE.hwnd, SW_MAXIMIZE
SetForegroundWindow Application.Hwnd 'Not working
Msgbox "IE Opened"
SetForegroundWindow IE.Hwnd
end sub