Reputation: 692
I am trying to export a file from IE, after selecting an item in dropdown by taking the Html ID and clicking the export option, but i am strucked while saving the file.
I am Selecting the option in the dropdown based on the value in an excel range.
Please help.
Below is the code I am trying.
Dim htm As Object
Dim IE As Object
Sub Website()
Dim Doc As Object
Set IE = CreateObject("internetexplorer.application")
IE.Visible = True
IE.navigate "http://**Link is confidential, sorry for not providing link**"
Do While IE.readystate <> 4: DoEvents: Loop
Set Doc = CreateObject("htmlfile")
Set Doc = IE.document
Set ref = Doc.getelementbyid("ReportViewerControl_ctl01_ctl05_ctl00")
For x = 0 To ref.Options.Length - 1
If ref.Options(x).Text = "Excel" Then
ref.selectedIndex = x
Set refclick = Doc.getelementbyid("ReportViewerControl_ctl01_ctl05_ctl01")
refclick.Click
Set refclick = Nothing
End If
Next
Set IE = Nothing
End Sub
And the snap shot I am strucked here, and here i want to save the file.
Upvotes: 5
Views: 17812
Reputation: 19406
I sent the keystrokes of the shortcut keys to click the save button in IE11.
Note: the code will not run as you expect if IE is not the active window on your machine so it won't work while in debug mode.
Application.SendKeys "%{S}"
Upvotes: 0
Reputation: 21
Add the following in your code:
Dim Report As Variant
Report = Application.GetSaveAsFilename("Attrition Report.xls", "Excel Files (*.xls), *.xls")
Upvotes: 2