1

So far the code opens our code goes to a patent website that uses javascript, inserts the desired record in the search box, executes the search and opens the legal status in a new window with only an address bar (not sure how it's called).

The problem is, this window is not active, and we cannot manipulate this window. Our goal is to gain the information that shows up in the popup window and export it to our excel sheet.

So the question is: How do we focus on this new window and what would be best practice to export this all to excel? Thanks in advance.

Sub internetform()
Dim IE As Object
Dim hWND As Long
Dim IEpopup As Object

'Dim doc As HTMLDocument
Dim pubno As String


Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://www.pss-system.gov.cn/sipopublicsearch/inportal/i18nAC.do?request_locale=en_US"
IE.Visible = True

While IE.Busy
        DoEvents
    Wend

pubno = ThisWorkbook.Sheets("Sheet1").Range("A1")

Application.Wait (Now() + TimeValue("00:00:02"))

IE.Document.All("searchInfo0").Value = pubno
While IE.Busy
DoEvents
Wend

IE.Document.All("executeSearch0").Click


Application.Wait (Now() + TimeValue("00:00:14"))
IE.Navigate "javascript:showAssisantTools_insearch('" & pubno & "','" & pubno & "',2)"


'FindWindow(vbNullString, pubno)
Application.Wait (Now() + TimeValue("00:00:02"))


'exporting div in body to excel
IE.Navigate "www.google.nl"
IE.Document.All("q").Value = pubno
Debug.Print IE.Document.All("bodyMid rop")

End Sub
Amar_97
  • 21
  • 4
  • [FindWindow](http://stackoverflow.com/questions/25098263/how-to-use-findwindow-to-find-a-visible-or-invisible-window-with-a-partial-name) API will most likely help. If this specific Q&A is not exactly what you need search around for more examples of FindWindow. You can pass the window title to find the window then you can loop through to find any clickable controls on the window. – Scott Holtzman May 01 '17 at 13:57
  • We managed to get an "invisible window handler" (not sure if this is correct as thewindow is visible). What should we do with this handler? – Amar_97 May 01 '17 at 14:18
  • This is a similar question which has an answer you can use: https://stackoverflow.com/questions/43722000/vba-get-and-manage-the-active-web-page-after-browser-closing-and-re-opening – Tim Williams May 01 '17 at 18:54

0 Answers0