Hi all,

I am using below code (method from this web) to extract data from the web, the problem I am facing is the popup alert message from the web which stop my procedure to further execute.

This is the web code of the search button (sorry that I dunno the reason of failure to post the full search button web code on the forum, so I just extract part of it)
HTML Code: 
Could anyone tell me how to solve the problem of frozen vba procedure after the popup of the alert? Many thanks!!

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

'Sends the specified message to a window or windows. The SendMessage function calls the window procedure
'for the specified window and does not return until the window procedure has processed the message.
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWND As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

'Retrieves a handle to the top-level window whose class name and window name match the specified strings.
'This function does not search child windows. This function does not perform a case-sensitive search.
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

'Retrieves a handle to a window whose class name and window name match the specified strings.
'The function searches child windows, beginning with the one following the specified child window.
'This function does not perform a case-sensitive search.
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long

Sub t1022()
Dim objie As Object
Dim i As Long, hWND As Long, childHWND As Long
Dim els As Object
Dim sessiontoken As Double

Set objie = CreateObject("InternetExplorer.Application")
objie.Visible = True
objie.Navigate "http://www.hkexnews.hk/sdw/search/search_sdw.asp"
Do: Sleep 100: Loop While objie.Busy

Set els = objie.Document.getElementById("mainform").getElementsByTagName("input")(8)
sessiontoken = els.DefaultValue

objie.Document.getElementById("txt_stock_code").innerText = "570"
objie.Document.all.Item("sel_ShareholdingDate_d").Value = "01"
objie.Document.all.Item("sel_ShareholdingDate_m").Value = "01"
objie.Document.all.Item("sel_ShareholdingDate_y").Value = "2015"
objie.Document.getElementsByTagName("a")(17).click ' after this line the procedure is frozen

For i = 1 To 10
    Sleep 100
    If Not objie.Busy Then Exit For
Next i
If objie.Busy Then
    'MsgBox "popup detected"
    DoEvents
hWND = FindWindow(vbNullString, "Message from webpage")
If hWND <> 0 Then childHWND = FindWindowEx(hWND, ByVal 0&, "Button", "OK")
If childHWND <> 0 Then SendMessage childHWND, BM_CLICK, 0, 0
End If
End Sub