我正在尝试从IE导出文件,在下拉列表中选择一个项目后,通过获取
Html ID并单击导出选项,但我在保存文件时被攻击.
我正在根据excel范围中的值选择下拉列表中的选项.
请帮忙.
以下是我正在尝试的代码.
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
快照我在这里被拍了,在这里我要保存文件.
最佳答案 在代码中添加以下内容:
Dim Report As Variant
Report = Application.GetSaveAsFilename("Attrition Report.xls", "Excel Files (*.xls), *.xls")