Make Selection from Website Popup Window

  • On a website, I click on tab that pulls up a popup window. From there I can make a selection which then pulls up more options on the same popup window. My code works to open the popup window, but how can I select an option from it to make my further selections?


    Here's what I have tried:


    Popup window code for the first option:


    Any help is greatly appreciated!


    Thanks,
    Hilary

  • Re: Make Selection from Website Popup Window


    You need to reference the HTMLDocument within the IE pop-up window, and you can get the IE pop-up window by looking for it in either Shell.Windows, SHDocVw.ShellWindows (the SHDocVw library also contains the InternetExplorer class), or using 'InternetExplorer With Events' and trapping the NewWindow2 event.

  • Re: Make Selection from Website Popup Window


    Hi John,


    This code works to click on the first "ETS" selection, but I can't seem to find the right code to get it to wait for the next window to load to make the next selection. It rolls right through the code before the choices are available.


  • Re: Make Selection from Website Popup Window


    It seems I was mistaken in thinking it was an IE window, so my last post doesn't apply.


    Based on this HTML:

    HTML
    <div id="ctl00_ContentPlaceHolder1_myFilter_pnlCOE" class="popupMenu" style="position: absolute; visibility: visible; left: 129px; top: 202px; width: 793px;">

    I am guessing that the pop-up window appears when the div's style contains "visible", so you could try something like this:

    Code
    Dim div As HTMLDivElement
    Do
        Set div = IE.document.getElementById("ctl00_ContentPlaceHolder1_myFilter_pnlCOE")
        DoEvents
    Loop Until Instr(div.style, "visible") > 0
  • Re: Make Selection from Website Popup Window


    Hi John,


    Thank you for your reply. I just got back to trying your code, and while I couldn't get it to work, I've decided to download the entire file without filtering it, (which I'll do later in Excel).


    I've gotten to the point where the bar comes up at the bottom of the popup window asking if I want to open, save, or cancel. I've tried many suggestions I've found on google, but nothing seems to work. My most recent trial was using modMain and modWindowsAPI, which I've updated for my 64-bit system, but my code gets stuck on the following code telling me the function is not defined. Although I see it on my modWindowsAPI module.


    Code
    hWnd = FindWindow("#32770", "Save As")


    I wish I could use WinHTTP or some other method to save the file, but the "Download" button URL changes every time the popup window loads, so that seems to be out the window. Is there another way to select "Save As"? I'm using IE11 now, but I'm afraid there will be other users of this code who will on 32-bit systems and using older versions of IE.


    Thank you,
    Hilary

  • Re: Make Selection from Website Popup Window


    Silly me, I left the copied Function as Private. Updated to Public and it reads.
    The code finishes through (according to dubug.print), but it doesn't actually download the file...

  • Re: Make Selection from Website Popup Window


    Quote from hilary4477;768776

    I've gotten to the point where the bar comes up at the bottom of the popup window asking if I want to open, save, or cancel.

    That means it's an IE9+ window. There is code linked from http://stackoverflow.com/quest…n-when-downloading-a-file which handles the IE download windows. I have code which does the same for IE8 - I think you must have found it with modWindowsAPI.


    Another way of controlling IE to download the file is with UIAutomationClient (set a reference to this library in your VBA project to get the classes) together with FindWindowEx to find the download notification bar.


    Without access to the website, I can't really help further. In any case, I think this has now moved away from the original goal of this thread, so I would start a new thread if you need help.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!