Pun*_* GP 5 excel internet-explorer vba excel-2007 save
在通过获取 Html ID 并单击导出选项在下拉列表中选择一个项目后,我试图从 IE 导出文件,但在保存文件时我被震惊了。
我正在根据 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
Run Code Online (Sandbox Code Playgroud)
我在这里被击中的快照,在这里我想保存文件。

小智 2
在您的代码中添加以下内容:
Dim Report As Variant
Report = Application.GetSaveAsFilename("Attrition Report.xls", "Excel Files (*.xls), *.xls")
Run Code Online (Sandbox Code Playgroud)