AnswerSeeker
06-01-2017, 01:13 AM
Hello folks,
for my work I regularly have to download data files from this page: https://www.regelleistung.net/ext/data/
There, I have to choose the time frame and two other options. To actually download it I have to check the box "Herunterladen". Final step is hitting the submit-button ("anzeigen") and the file is saved automatically in the standard 'download' folder. My goal is to automate this process in excel: user input for all four options should be taken from input cells in excel.
My problem is to not be able to download it. I could not figure out a complete URL-address, since the file is only generated after hitting the submit-button. Instead of I tried it via automatically hitting the buttons, see code below (copied it from other forums):
Sub Test()
Dim ie As Object
Dim frm As Variant
Dim element As Variant
wbDir = ActiveWorkbook.Path
wbAE = ActiveWorkbook.Name
startdate = Format(Workbooks(wbAE).Worksheets("test").Range("E11"), "dd.mm.yyyy")
enddate = Format(Workbooks(wbAE).Worksheets("test").Range("E12"), "dd.mm.yyyy")
' Create InternetExplorer Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
' Send the form data To URL As POST binary request
ie.navigate "https://www.regelleistung.net/ext/data/"
' Wait while IE loading...
While ie.Busy
DoEvents
Wend
ie.document.getElementById("form-from-date").Value = startdate
ie.document.getElementById("form-to-date").Value = enddate
ie.document.getElementById("form-tso").Value = "6"
ie.document.getElementById("form-type").Value = "RZ_SALDO"
ie.document.getElementById("form-download").Checked = True
ie.document.getElementById("submit-button").Click
End Sub
When I execute the code, an IE window pop up with all options chosen correctly. However, I am still unable to download it indicated by field end date ("bis") which is greyed out. Only after I re-ckecked the checkbox ("herunterladen") I am able to download it (indicated by white background of the field for end date).
I hope you can help.
Cheers
for my work I regularly have to download data files from this page: https://www.regelleistung.net/ext/data/
There, I have to choose the time frame and two other options. To actually download it I have to check the box "Herunterladen". Final step is hitting the submit-button ("anzeigen") and the file is saved automatically in the standard 'download' folder. My goal is to automate this process in excel: user input for all four options should be taken from input cells in excel.
My problem is to not be able to download it. I could not figure out a complete URL-address, since the file is only generated after hitting the submit-button. Instead of I tried it via automatically hitting the buttons, see code below (copied it from other forums):
Sub Test()
Dim ie As Object
Dim frm As Variant
Dim element As Variant
wbDir = ActiveWorkbook.Path
wbAE = ActiveWorkbook.Name
startdate = Format(Workbooks(wbAE).Worksheets("test").Range("E11"), "dd.mm.yyyy")
enddate = Format(Workbooks(wbAE).Worksheets("test").Range("E12"), "dd.mm.yyyy")
' Create InternetExplorer Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
' Send the form data To URL As POST binary request
ie.navigate "https://www.regelleistung.net/ext/data/"
' Wait while IE loading...
While ie.Busy
DoEvents
Wend
ie.document.getElementById("form-from-date").Value = startdate
ie.document.getElementById("form-to-date").Value = enddate
ie.document.getElementById("form-tso").Value = "6"
ie.document.getElementById("form-type").Value = "RZ_SALDO"
ie.document.getElementById("form-download").Checked = True
ie.document.getElementById("submit-button").Click
End Sub
When I execute the code, an IE window pop up with all options chosen correctly. However, I am still unable to download it indicated by field end date ("bis") which is greyed out. Only after I re-ckecked the checkbox ("herunterladen") I am able to download it (indicated by white background of the field for end date).
I hope you can help.
Cheers