我正在尝试替换每天下载的文档。但是我点击下载按钮后不知道自己需要做什么。我需要在文档中保存具有特定名称的文档
按照代码:
Dim IE As Object
Dim n, Period1, Period2 As Double
'retorna o internet explorer-return the correct period
Period1 = "201612"
Period2 = "201612"
'abre o internet explorer
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://www2.susep.gov.br/menuestatistica/SES/principal.aspx"
IE.Visible = True
Application.Wait (Now + TimeValue("00:00:02"))
'seleciona as operações desejadas
IE.document.getElementById("ctl00_ContentPlaceHolder1_edSelProd").SelectedIndex = "8"
IE.document.getElementById("ctl00_ContentPlaceHolder1_btnConsultar").Click
'seleciona o periodo
Application.Wait (Now + TimeValue("00:00:02"))
Set ieDoc = IE.document
ieDoc.getElementById("ctl00_ContentPlaceHolder1_edInicioPer").Value = Period1
ieDoc.getElementById("ctl00_ContentPlaceHolder1_edFimPer").Value = Period2
'seleciona as empresas
IE.document.getElementById("ctl00_ContentPlaceHolder1_edEmpresas").SelectedIndex = "0"
ieDoc.getElementById("ctl00_ContentPlaceHolder1_Button1").Click
Application.Wait (Now + TimeValue("00:00:02"))
ieDoc.getElementById("ctl00_ContentPlaceHolder1_Button1").Click
答案 0 :(得分:0)
我尝试找到其他使用命令直接保存文件的解决方案,但似乎您需要尝试不推荐的注册表项。所以我以下面的方式做到了
IE.document.getElementById("downXls").Click
Application.Wait (Now + TimeValue("0:00:7"))
CreateObject("WScript.Shell").SendKeys "%s"
Application.Wait Now + TimeValue("00:00:02")
IE.Quit
Application.DisplayAlerts = False
FSO.MoveFile Source:=sfolder & "ValueResearch-Stocks-" & vert & "-" & dateval & ".xls", Destination:=DestinFileName
FSO.MoveFile Source:=sfolder & "ValueResearch-Stocks-" & vert & "-" & dateval & ".xlsx", Destination:=DestinFileName
因此,您需要在变量中定义路径,然后只需将下载的文件移动到所需位置