Sharid
Well-known Member
- Joined
- Apr 22, 2007
- Messages
- 1,064
- Office Version
- 2016
- Platform
- Windows
I am using this code to keep my userform on top, however my IE goes behind this, I tried to set focus on the IE but it is not working
I tried this and get the following error message
I have also tried this and get another error message
VBA Code:
'Summary: Keeps a UserForm on top of all other Windows.
'API Call Declarations
Public Declare PtrSafe Function GetActiveWindow _
Lib "user32.dll" () As Long
Private Declare PtrSafe Function SetWindowPos _
Lib "user32.dll" _
(ByVal hWnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
'VBA Macro
Public Sub KeepFormOnTop()
Dim hWnd As Long
Dim RetVal As Long
Const HWND_TOPMOST = -1
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
hWnd = GetActiveWindow()
RetVal = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE)
End Sub
I tried this and get the following error message
VBA Code:
Set objIE = New InternetExplorer 'initiating a new instance of Internet Explorer and assigning it to objIE
objIE.Visible = True
objIE.document.Focus ()
I have also tried this and get another error message
VBA Code:
Set objIE = New InternetExplorer 'initiating a new instance of Internet Explorer and assigning it to objIE
objIE.Visible = True
objIE.document.Focus () = True