0

im looping through elements on a webpage as

Select element click button to generate report Click link to download report click Save in IE Open/Save/Cancel bar

Open/Save/Cancel dialog

It appears, the download link doesnt always result in Open/Save/Cancel of Explorer to appear. Open/Save/Cancel, however, always appear if the linked pressed second time. I ideally should be checking why this happens, but as a shortcut Im trying to check if Open/Save/Cancel dialog is there and, if not, click the Download link again. Below is the code

For Each el In l
  If el.innertext = "View Bill" Then
  el.Click
  Application.Wait (Now + TimeValue("0:00:03"))
  If Application.Dialogs(xlDialogSaveAs).Show Then '.Show Then
  Application.SendKeys ("%s")
  Else
    el.Click 
    Application.Wait (Now + TimeValue("0:00:03"))
    Application.SendKeys ("%s")
    End If
    Else
  End If
Next el

I expected Application.Dialogs(xlDialogSaveAs).Show to check if the Save bar is there. It might do, it might not, but the Application.Sendkeys sends Save command to the workbook im running the code from and not to the Save dialog.

Any suggestions on how to check for the Save dialog or focus back on it so Sendkeys works?

Thank you.

Community
  • 1
  • 1
Pavel
  • 1
  • ps: exluding solution presented here http://stackoverflow.com/questions/26038165/automate-saveas-dialouge-for-ie9-vba , as im on working laptop, wont get to copy the dll – Pavel Apr 27 '17 at 13:30
  • adding IE.Document.Focus after Wait still makes the code to send Sendkeys combination to the Excel Workbook instead of IE. – Pavel Apr 27 '17 at 14:27

0 Answers0