title: How do I set the caption of a window in VBA using SetWindowText and its handle?
body: <p>I am using VBA from 32-bit Excel 365, on Windows 10.</p>
  <p>Assuming that I have the handle of a notepad window in <code>hWndApp</code>, why does the following not set the caption of the window? Rather, it appears to do nothing.</p>
  <pre><code>Private Declare Function SetWindowText Lib &quot;user32&quot; _
     Alias &quot;SetWindowTextA&quot; _
    (ByVal hwnd As Long, ByVal _
     lpString As String) As Long
  
  Call SetWindowText(hWndApp, &quot;The handle to notepad is &quot; &amp; CStr(hWndApp))
  </code></pre>