Hi i am writing a code to simplify some tasks at work. there is a website that we visit regularly to get rainfall data from and its wastes allot of time filling out irrelevant data. i have written the code to open IE fill out requested data and generate tables. there is a button which opens a downloadable CSV file but for the life of me i cant get it working. my code looks like this so far
Function FillInternetForm()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
'create new instance of IE. use reference to return current open IE if
'you want to use open IE window. Easiest way I know of is via title bar.
ie.navigate "https://hirds.niwa.co.nz/"
'go to web page listed inside quotes
ie.Visible = True
While ie.busy
DoEvents 'wait until IE is done loading page.
Wend
Application.Wait (Now + TimeValue("00:00:05"))
ie.Document.All("address").Value = ThisWorkbook.Sheets("sheet1").Range("b1")
While ie.busy
DoEvents 'wait until IE is done loading page.
Wend
ie.Document.All("SubmitForm").Click
While ie.busy
DoEvents 'wait until IE is done loading page.
Wend
ie.Document.All("sitename").Value = ThisWorkbook.Sheets("sheet1").Range("b2")
While ie.busy
DoEvents 'wait until IE is done loading page.
Wend
ie.Document.All("tempchange1").Value = ThisWorkbook.Sheets("sheet1").Range("b3")
While ie.busy
DoEvents 'wait until IE is done loading page.
Wend
ie.Document.All("tempchange2").Value = ThisWorkbook.Sheets("sheet1").Range("b3")
While ie.busy
DoEvents 'wait until IE is done loading page.
Wend
ie.Document.All("tempchange3").Value = ThisWorkbook.Sheets("sheet1").Range("b3")
While ie.busy
DoEvents 'wait until IE is done loading page.
Wend
ie.Document.All("calculation").Value = "IFD"
Application.Wait (Now + TimeValue("00:00:05"))
ie.Document.getElementByid("create").Click
End Function
i have attached 2 files showing what my spreadsheet looks like at the moment and what the hirds website looks like (showing the CSV download link) Hirds.JPG spreadsheet.JPG
if anyone could point me in the right direction that would be great.
Bookmarks