title: VBA to click IE11 Save As dialogue in Win7x64
body: <p>I'm trying to get VBA to automate saving a file from IE. Thanks to various posts on these forums, I can login, navigate pages, and click the download link. The Save prompt appears at the bottom of IE, then I'm stuck:</p>
  
  <p><a href="https://i.stack.imgur.com/sCpWm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sCpWm.jpg" alt="IE11 Save Dialogue"></a></p>
  
  <p>I've been trying to use the code samples from <a href="https://www.mrexcel.com/forum/excel-questions/502298-need-help-regarding-ie-automation-using-vba-post3272730.html#post3272730" rel="nofollow noreferrer">https://www.mrexcel.com/forum/excel-questions/502298-need-help-regarding-ie-automation-using-vba-post3272730.html#post3272730</a>, but the second FindWindow always returns 0:</p>
  
  <pre><code>hWnd = FindWindowEx(hWnd, 0, "DUIViewWndClassName", vbNullString) 
  </code></pre>
  
  <p>I'm using VBA 7.0 in Excel 14, and IE11. </p>
  
  <p>There is advice at the top of the original post:</p>
  
  <blockquote>
    <p>'Note - IE may block the download, displaying its Information Bar at
    the top of the tab, and preventing this program from 'automatically
    downloading the file.  To prevent this, add NRLDC to IE's Trusted
    sites (Tools - Internet Options - 'Security - Trusted sites - Sites)</p>
  </blockquote>
  
  <p>I can't access the trusted sites list due to IT policy, but the download prompt appears, so I don't think this is the issue.</p>
  
  <p>The code I've taken is from <a href="https://www.mrexcel.com/forum/members/doongie.html" rel="nofollow noreferrer">Doongie</a>'s <a href="https://www.mrexcel.com/forum/excel-questions/502298-need-help-regarding-ie-automation-using-vba-post3550759.html#post3550759" rel="nofollow noreferrer">reply</a>, which indicates it's updated for Windows 7:</p>
  
  <pre><code>Private Sub File_Download_Click_Save()
  
      Dim hWnd As Long
      Dim timeout As Date
  
      Debug.Print "File_Download_Click_Save"
  
      'Find the File Download window, waiting a maximum of 30 seconds for it to appear
  
      timeout = Now + TimeValue("00:00:30")
      Do
          hWnd = FindWindow("#32770", "") 'returns various numbers on different runs: 20001h 10440h
          DoEvents
          Sleep 200
      Loop Until hWnd Or Now &gt; timeout
  
      Debug.Print "   File Download window "; Hex(hWnd)
  
      If hWnd Then
          SetForegroundWindow hWnd
  
          'Find the child DUIViewWndClassName window
          hWnd = FindWindowEx(hWnd, 0, "DUIViewWndClassName", vbNullString)    'always returns 0
          Debug.Print "   DUIViewWndClassName "; Hex(hWnd)
      End If
  
      If hWnd Then
          'Find the child DirectUIHWND window
          hWnd = FindWindowEx(hWnd, 0, "DirectUIHWND", "")
          Debug.Print "   DirectUIHWND "; Hex(hWnd)
      End If
  
      If hWnd Then
          'Find the child FloatNotifySink window
          hWnd = FindWindowEx(hWnd, 0, "FloatNotifySink", "")
          Debug.Print "   FloatNotifySink "; Hex(hWnd)
      End If
  
      If hWnd Then
          'Find the child ComboBox window
          hWnd = FindWindowEx(hWnd, 0, "ComboBox", "")
          Debug.Print "   ComboBox "; Hex(hWnd)
      End If
  
      If hWnd Then
          SetForegroundWindow hWnd
  
          'Find the child Edit window
          hWnd = FindWindowEx(hWnd, 0, "Edit", "")
          Debug.Print "   Edit "; Hex(hWnd)
      End If
  
      If hWnd Then        
          'Click the Save button
          SetForegroundWindow hWnd
          Sleep 600  'this sleep is required and 600 milliseconds seems to be the minimum that works
          SendMessage hWnd, BM_CLICK, 0, 0
      End If
  
  End Sub
  </code></pre>
  
  <p>Is there any way (that won't get me in trouble with IT!) that I can inspect the handle numbers of the IE elements? Code inspector only shows me the page code, not IE dialogues.</p>
  
  <p>Is there a list of possible element names for <code>lpsz1</code> defined somewhere, as they apply to elements of IE?</p>
  
  <pre><code>Public Declare PtrSafe Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
      (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
  </code></pre>