I am trying to download a report from my company's site for reporting purposes.
Steps for:
- Open IE
- Go to download link
- Click on extract button
- click on open button on the IE dialog box(save/open/cancel box)
- Copy the data to sheet 1 of my active workbook
- Close IE
I have done till step 3. I am having trouble with step 4. I tried the below solutions but they did not work for me.
How to check if Open/Save/Cancel bar appeared
Automate saveas dialogue for IE9 (vba)
Code Used:
Sub ExtractGLfile()
Set ie = New InternetExplorerMedium
Dim DLCPortalGL As String
DLCPortalGL = "link"
ie.Visible = True
ie.navigate (DLCPortalGL)
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
ie.document.getElementById("ButtonID").Click
I need help with step 4 - clicking on open of the open/save/cancel button.
UPDATES: I was able to download the file using the below code
Application.SendKeys "%{O}", True
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
However while the file opens, I am getting error: enter image description here Any suggestions?