With Stackoverflow, I reached the following code; it basically opens IE, navigates to the URL, fills out the form, and submits.
Sub getdata()
Application.ScreenUpdating = False
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "http://www.bseindia.com/markets/equity/EQReports/BulknBlockDeals.aspx?expandable=7"
Application.StatusBar = "Submitting"
' Wait while IE loading...
While IE.Busy
DoEvents
Wend
' **********************************************************************
delay 5
IE.document.getElementbyid("ctl00_ContentPlaceHolder1_chkAllMarket").Click
delay 5
IE.document.getElementbyid("ctl00_ContentPlaceHolder1_txtDate").Value = "01/01/2014"
delay 5
IE.document.getElementbyid("ctl00_ContentPlaceHolder1_txtToDate").Value = "12/01/2014"
delay 5
IE.document.getElementbyid("ctl00_ContentPlaceHolder1_btnSubmit").Click
delay 5
'''IE.document.getElementbyid("ctl00_ContentPlaceHolder1_btnDownload").Click
'''(Commented as the click gives the option asking to save, open the csv file)
'**********************************************************************
Application.StatusBar = "Form Submitted"
'IE.Quit 'will uncomment line once working
'Set IE = Nothing 'will uncomment line once working
Application.ScreenUpdating = True
End Sub
Private Sub delay(seconds As Long)
Dim endTime As Date
endTime = DateAdd("s", seconds, Now())
Do While Now() < endTime
DoEvents
Loop
End Sub
Problem:
After submitting the form, the data is filled on the screen, as well as the Excel icon (Download) with the same data in csv.
How can I get this data (any way is ok) on my active sheet.
Vasim source
share