如何从Excel VBA从页面保存文件? [英] How to save file from Webpage from Excel VBA?
本文介绍了如何从Excel VBA从页面保存文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图从IE导出一个文件,在下拉列表中选择一个项目后,通过获取Html ID并点击导出选项,但是我在保存文件时被击中。
我正在选择根据excel范围内的值,下拉列表中的选项。
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.
推荐答案
在您的代码中添加以下内容:
Add the following in your code:
Dim Report As Variant
Report = Application.GetSaveAsFilename("Attrition Report.xls", "Excel Files (*.xls), *.xls")
这篇关于如何从Excel VBA从页面保存文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文