Consulting

Results 1 to 1 of 1

Thread: VBA Interacting With A Child Window

  1. #1
    VBAX Newbie
    Joined
    Mar 2016
    Posts
    1
    Location

    VBA Interacting With A Child Window

    I'm working on my first web scraper. Basically I need to scrape from a parent page and a child page. The parent page has a list of items (names and product #, etc). I can scrape this general information from the parent page without problems. But, I also need to scrape the details of each item. To do this I need to click on each item and set the focus on the child window that pops up with the detail information. However, I can't get the program to change focus from the parent page to the child window so that I can scrape the details for the item clicked. It's very frustrating. How do I get my [/FONT]VBA[COLOR=#222426][FONT=Arial] code to change from the parent's page collection to the child's collection?
    Dim ie As InternetExplorer
    Dim Document As HTMLDocument
    Dim ele As Object, myURL as String
    Dim Document As HTMLDocument
    Dim AllLinks As IHTMLElementCollection
    
    Set ie = New InternetExplorer
    myURL = Range("Website").Value ‘URL is set in a named range on the spreadsheet
    ie.navigate (myURL) 
    Do While ie.Busy Or ie.readyState <> 4
    DoEvents
    Loop
    
    For Each ele In ie.Document.all
    Set AllLinks = ie.Document.getElementsByTagName("a")
    For Each Hyperlink In AllLinks
    ‘There are several frames, so only open the one where criteria is met 
    If InStr(Hyperlink.href, "Product1234") And InStr(Hyperlink.innerText, "Details") Then
    ‘Opens child window 
    Hyperlink.Click
    ‘NEED CODE HERE TO INTERACT WITH CHILD FRAME WINDOW THEN GO BACK TO PARENT WINDOW
    End if
    Next Hyperlink
    Next ele
    Thanks for the help.
    Last edited by Bob Phillips; 03-03-2016 at 04:18 PM. Reason: Added VBA tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •