redbaron06
New Member
- Joined
- Aug 6, 2010
- Messages
- 44
Hi All,
I was hoping that someone could help me to alternatively automate the IE File Download Dialog Box in VBA (and a second box that states the user opening a file in a different format than stated). I used SendKeys in my code below, which works, sometimes. I have searched high and low to no avail and could use some expert advice.
The code I am using navigates IE to a page, clicks on an image to export the document, and then attempts to click open and ok to open the new workbook. SaveTheData simply activates the other workbook (the new export) then saving and closing it to a specificed destination.
Thanks in advance!
I was hoping that someone could help me to alternatively automate the IE File Download Dialog Box in VBA (and a second box that states the user opening a file in a different format than stated). I used SendKeys in my code below, which works, sometimes. I have searched high and low to no avail and could use some expert advice.
The code I am using navigates IE to a page, clicks on an image to export the document, and then attempts to click open and ok to open the new workbook. SaveTheData simply activates the other workbook (the new export) then saving and closing it to a specificed destination.
Thanks in advance!
Code:
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
'Get the HTML document of the new page
Set doc = IE.document
max = 10000
For i = 0 To max
If doc.getElementsByTagName("img").Item(i).getAttribute("title") = "Export data in Excel" Then
doc.getElementsByTagName("img").Item(i).Click
Exit For
End If
Next
[B]Application.Wait (Now + TimeValue("0:00:02"))[/B]
[B] SendKeys "{TAB}", True[/B]
[B] SendKeys "{TAB}", True[/B]
[B] SendKeys "{ENTER}", True[/B]
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:04"))
Call SaveTheFile