Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Is this what you are trying? This is based on <code>THEORY 2</code></p> <pre><code>Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Declare Function GetForegroundWindow Lib "user32" () As Long Const SW_MINIMIZE = 6 Const SW_RESTORE = 9 Private Sub UserForm_Initialize() Application.Visible = False End Sub Private Sub CommandButton1_Click() Dim hwnd As Long, RetVal As Long hwnd = FindWindow("ThunderDFrame", Me.Caption) RetVal = ShowWindow(hwnd, SW_MINIMIZE) '~~&gt; This is required so that GetForegroundWindow '~~&gt; doesn't pick up the userforms handle Sleep 2000 hwnd = GetForegroundWindow() If GetIEByHWND(hwnd) Is Nothing Then MsgBox "Not Able to get the object" Else MsgBox "Was able to get the object" End If RetVal = ShowWindow(hwnd, SW_RESTORE) Application.Visible = True End Sub Function GetIEByHWND(myHWND As Long) As Object Dim tempWindow As Variant Dim objShellWindows As New SHDocVw.ShellWindows Set GetIEByHWND = Nothing For Each tempWindow In objShellWindows If InStr(1, tempWindow.Path, "INTERNET", vbTextCompare) Then If myHWND = tempWindow.hwnd Then Set GetIEByHWND = tempWindow Exit For End If End If Next tempWindow End Function </code></pre> <p><strong>FOLLOWUP</strong></p> <p>See this code where I am interacting with the IE object.</p> <pre><code>Private Sub CommandButton1_Click() Dim hwnd As Long, RetVal As Long Dim IE As Object hwnd = FindWindow("ThunderDFrame", Me.Caption) RetVal = ShowWindow(hwnd, SW_MINIMIZE) '~~&gt; This is required to that GetForegroundWindow '~~&gt; doesn't pick up the userforms handle Sleep 2000 hwnd = GetForegroundWindow() Set IE = GetIEByHWND(hwnd) If IE Is Nothing Then MsgBox "Not Able to get the object" Else MsgBox "Was able to get the object" IE.Visible = False '&lt;~~ Interacting with IE Sleep 2000 IE.Visible = True End If RetVal = ShowWindow(hwnd, SW_RESTORE) Application.Visible = True End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload