locked
FindWindowEx throws invalid use of null in VBA. RRS feed

  • Question

  • Hello all, I have gotten to the point in my code through the IE interface to click on a link that brings up the file download dialog box,  now however I am trying to get the address of the save button in the file download dialog with the following commands.

     

    Do Until WindowOpen <> 0 'wait for the "File Download" popup window to appear
            WindowOpen = FindWindow(vbNullString, "File Download")
          Loop
          'Find the save button in the File Download Dialog box.
          'throws error 94 invalid use of null
          ButtonSave = FindWindowEx(WindowOpen, Null, "Button", "Save")
          SetActiveWindow (WindowOpen)
          SendMessage ButtonSave, BM_CLICK, 0, 0 'Click "Save" Button
    

    What happens is when I call FindWindowEx is I keep getting an invalid use of null I have also tried &Save but that doesn't work either,

    This is my declaration in VBA Excel 2003, to access the library.

    Private Declare Function FindWindowEx Lib "user32" (ByVal hWnd1 As Long, _
    ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

     

    Wednesday, October 13, 2010 10:16 PM